more debugging
authorChristos Zoulas <christos@zoulas.com>
Sun, 20 Jul 2014 19:26:31 +0000 (15:26 -0400)
committerChristos Zoulas <christos@zoulas.com>
Sun, 20 Jul 2014 19:26:31 +0000 (15:26 -0400)
amd/readdir.c

index aa9ae6b84841f09196d0959b6a7f82f328c8caf1..511bdc047fbe32a0742114bbd1f8d9a1346416a4 100644 (file)
@@ -388,8 +388,11 @@ amfs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int
      *      4byte name length
      *      4byte name
      * plus the dirlist structure */
-    if (count < (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp))))
+#define NEEDROOM (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp)))
+    if (count < NEEDROOM) {
+      dlog("%s: not enough room %u < %zu", __func__, count, NEEDROOM);
       return EINVAL;
+    }
 
     xp = next_nonerror_node(mp->am_child);
     dp->dl_entries = ep;
@@ -812,8 +815,11 @@ amfs_readdir3(am_node *mp, am_cookie3 cookie,
      *      8byte next entry addres) = sizeof(*ep)
      *      2byte name + 1byte terminator
      * plus the dirlist structure */
-    if (count < ((2 * ((sizeof(*ep) + sizeof("..") + 1))) + sizeof(*dp)));
+#define NEEDROOM3 ((2 * ((sizeof(*ep) + sizeof("..") + 1))) + sizeof(*dp))
+    if (count < NEEDROOM3) {
+      dlog("%s: not enough room %u < %zu", __func__, count, NEEDROOM3);
       return EINVAL;
+    }
 
     xp = next_nonerror_node(mp->am_child);
     dp->entries = ep;