Przeglądaj źródła

add note about racecondition

Mike Frysinger 19 lat temu
rodzic
commit
71b20283a6
1 zmienionych plików z 5 dodań i 0 usunięć
  1. 5 0
      libc/misc/dirent/opendir.c

+ 5 - 0
libc/misc/dirent/opendir.c

@@ -42,6 +42,11 @@ DIR *opendir(const char *name)
 #endif
 #endif
 	if ((fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
 	if ((fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
 		return NULL;
 		return NULL;
+	/* Note: we should check to make sure that between the stat() and open()
+	 * call, 'name' didnt change on us, but that's only if O_DIRECTORY isnt
+	 * defined and since Linux has supported it for like ever, i'm not going
+	 * to worry about it right now (if ever). */
+
 	/* According to POSIX, directory streams should be closed when
 	/* According to POSIX, directory streams should be closed when
 	 * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
 	 * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
 	 */
 	 */