Skip to contentSkip to conversation

rpcbind: avoid dereferencing NULL from realloc()

PATCH In review Zhi Li 2 participants 2 messages Feb 28, 2023 – Nov 11, 2024

Subsystems (2)
lore
Share & tools
lore

Zhi Li

author
#0 lore raw

PATCH 1/1 rpcbind: avoid dereferencing NULL from realloc()

---
 src/rpcbind.c | 2 ++
 1 file changed, 2 insertions(+)
src/rpcbind.c +2 -0
index ecebe97..6379a4e 100644
@@ -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 {
Signature · 1 line
2.39.0
#1 lore raw
Quoted 3 lines · Zhi Li

Committed... (tag: rpcbind-1_2_8-rc2)

steved.

Quoted 19 lines
---
  src/rpcbind.c | 2 ++
  1 file changed, 2 insertions(+)
src/rpcbind.c +2 -1
index ecebe97..6379a4e 100644
@@ -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