Linux NFS development
 help / color / mirror / Atom feed
* nfsd: fix memory overflow for haddr
@ 2026-07-14  8:43 zhangjian (CG)
  2026-07-14 15:16 ` Chuck Lever
  0 siblings, 1 reply; 2+ messages in thread
From: zhangjian (CG) @ 2026-07-14  8:43 UTC (permalink / raw)
  To: steved, chuck.lever; +Cc: linux-nfs

when hcounter is not 0, haddr memory is not enough.
asan report heap-buffer-overflow error in following scene:
CFLAGS="-fsanitize=address -g" ./configure && make
./utils/nfsd/nfsd -H 192.168.1.1 -H 192.168.1.2

Signed-off-by: zhangjian <zhangjian496@huawei.com>
---
 utils/nfsd/nfsd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index c95d32f4..e3fcdde4 100644
--- a/utils/nfsd/nfsd.c
+++ b/utils/nfsd/nfsd.c
@@ -185,7 +185,7 @@ main(int argc, char **argv)
 				hcounter = 0;
 			}
 			if (hcounter) {
-				haddr = realloc(haddr, sizeof(char*) * hcounter+1);
+				haddr = realloc(haddr, sizeof(char*) * (hcounter+1));
 				if(!haddr) {
 					fprintf(stderr, "%s: unable to allocate "
 							"memory.\n", progname);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-14 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14  8:43 nfsd: fix memory overflow for haddr zhangjian (CG)
2026-07-14 15:16 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox