2023-02-28 08:36:38

by Zhi Li

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

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

Signed-off-by: Zhi Li <[email protected]>
---
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