From a27836bad7fedfe92637c78af4f1d0e83d8d2b85 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Sun, 20 Jul 2014 15:26:31 -0400 Subject: [PATCH] more debugging --- amd/readdir.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/amd/readdir.c b/amd/readdir.c index aa9ae6b8..511bdc04 100644 --- a/amd/readdir.c +++ b/amd/readdir.c @@ -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; -- 2.34.1