readdir: be more conservative with directory entry names
[linux-2.6-block.git] / fs / readdir.c
index d26d5ea4de7b8958ea3d48069cd873b50398cd88..03eedaf36134f49b72bf57c7568429e5c1235cd6 100644 (file)
@@ -102,10 +102,14 @@ EXPORT_SYMBOL(iterate_dir);
  * filename length, and the above "soft error" worry means
  * that it's probably better left alone until we have that
  * issue clarified.
+ *
+ * Note the PATH_MAX check - it's arbitrary but the real
+ * kernel limit on a possible path component, not NAME_MAX,
+ * which is the technical standard limit.
  */
 static int verify_dirent_name(const char *name, int len)
 {
-       if (!len)
+       if (len <= 0 || len >= PATH_MAX)
                return -EIO;
        if (memchr(name, '/', len))
                return -EIO;