Whamcloud - gitweb
libe2p: Fix potential core-dumping bug in iterate_on_dir()
authorTheodore Ts'o <tytso@mit.edu>
Mon, 1 Sep 2008 13:38:32 +0000 (09:38 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 1 Sep 2008 13:38:32 +0000 (09:38 -0400)
iterate_on_dir() can try to copy too much data from the directory
entry, resulting in a crash.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/e2p/iod.c

index 2c675b9..1edfc4f 100644 (file)
@@ -56,12 +56,12 @@ int iterate_on_dir (const char * dir_name,
                return -1;
        }
        while ((dep = readdir (dir))) {
-               len = sizeof(struct dirent);
 #ifdef HAVE_RECLEN_DIRENT
-               if (len < dep->d_reclen)
-                       len = dep->d_reclen;
+               len = dep->d_reclen;
                if (len > max_len)
                        len = max_len;
+#else
+               len = sizeof(struct dirent);
 #endif
                memcpy(de, dep, len);
                if ((*func)(dir_name, de, private))