[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-nfs
Subject:    [PATCH] [nfs/nfs-utils/rpcbind] rpcbind: avoid dereferencing NULL from realloc()
From:       Zhi Li <yieli () redhat ! com>
Date:       2023-02-28 8:35:44
Message-ID: 20230228083544.4035733-1-yieli () redhat ! com
[Download RAW message or body]

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

Signed-off-by: Zhi Li <yieli@redhat.com>
---
 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic