diff mbox series

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

Message ID 20230228083544.4035733-1-yieli@redhat.com (mailing list archive)
State New, archived
Headers show
Series [nfs/nfs-utils/rpcbind] rpcbind: avoid dereferencing NULL from realloc() | expand

Commit Message

Zhi Li Feb. 28, 2023, 8:35 a.m. UTC
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(+)

Comments

Steve Dickson Nov. 11, 2024, 5:29 p.m. UTC | #1
On 2/28/23 2:35 AM, Zhi Li wrote:
> Fixes:https://bugzilla.redhat.com/show_bug.cgi?id=2173869
> 
> Signed-off-by: Zhi Li<yieli@redhat.com>
Committed... (tag: rpcbind-1_2_8-rc2)

steved.

> ---
>   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
>
diff mbox series

Patch

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 {