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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux