nfsd: fix memory overflow for haddr
"zhangjian (CG)" <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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