Thread (2 messages) 2 messages, 2 authors, 2024-11-11
STALE577d

[PATCH] [nfs/nfs-utils/rpcbind] rpcbind: avoid dereferencing NULL from realloc()

From: Zhi Li <hidden>
Date: 2023-02-28 08:36:38
Subsystem: the rest · Maintainer: Linus Torvalds

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2173869

Signed-off-by: Zhi Li <redacted>
---
 src/rpcbind.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/src/rpcbind.c b/src/rpcbind.c
index ecebe97..6379a4e 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -471,6 +471,8 @@ init_transport(struct netconfig *nconf)
 		nhostsbak = nhosts;
 		nhostsbak++;
 		hosts = realloc(hosts, nhostsbak * sizeof(char *));
+		if (hosts == NULL)
+			errx(1, "Out of memory");
 		if (nhostsbak == 1)
 			hosts[0] = "*";
 		else {
-- 
2.39.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help