Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/pax Check for another race reported by chuq.



details:   https://anonhg.NetBSD.org/src/rev/bb9e6eefa1cb
branches:  trunk
changeset: 584451:bb9e6eefa1cb
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 18 12:15:41 2005 +0000

description:
Check for another race reported by chuq.

diffstat:

 bin/pax/file_subs.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 95b3d7581d78 -r bb9e6eefa1cb bin/pax/file_subs.c
--- a/bin/pax/file_subs.c       Sat Sep 17 19:39:48 2005 +0000
+++ b/bin/pax/file_subs.c       Sun Sep 18 12:15:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: file_subs.c,v 1.56 2005/09/16 16:48:18 christos Exp $  */
+/*     $NetBSD: file_subs.c,v 1.57 2005/09/18 12:15:41 christos Exp $  */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)file_subs.c        8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: file_subs.c,v 1.56 2005/09/16 16:48:18 christos Exp $");
+__RCSID("$NetBSD: file_subs.c,v 1.57 2005/09/18 12:15:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -749,7 +749,14 @@
                *(spt++) = '/';
                continue;
        }
-       return(retval);
+       /*
+        * We perform one final check here, because if someone else
+        * created the directory in parallel with us, we might return
+        * the wrong error code, even if the directory exists now.
+        */
+       if (retval == -1 && stat(name, &sb) == 0 && S_ISDIR(sb.st_mode))
+               retval = 0;
+       return retval;
 }
 
 /*



Home | Main Index | Thread Index | Old Index