linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [nfs/nfs-utils] mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket
@ 2022-10-21 12:41 Zhi Li
  2022-10-24 17:37 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Zhi Li @ 2022-10-21 12:41 UTC (permalink / raw)
  To: linux-nfs; +Cc: steved, Zhi Li

In function nfs_parse_square_bracket, hostname could be NULL,
dereferencing it in free(*hostname) may cause an unexpected segfault.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2136807
Signed-off-by: Zhi Li <yieli@redhat.com>
---
 utils/mount/parse_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c
index 0d3bcb95..2ade5d5d 100644
--- a/utils/mount/parse_dev.c
+++ b/utils/mount/parse_dev.c
@@ -170,7 +170,8 @@ static int nfs_parse_square_bracket(const char *dev,
 	if (pathname) {
 		*pathname = strndup(cbrace, path_len);
 		if (*pathname == NULL) {
-			free(*hostname);
+			if (hostname)
+				free(*hostname);
 			return nfs_pdn_nomem_err();
 		}
 	}
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [nfs/nfs-utils] mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket
  2022-10-21 12:41 [PATCH] [nfs/nfs-utils] mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket Zhi Li
@ 2022-10-24 17:37 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2022-10-24 17:37 UTC (permalink / raw)
  To: Zhi Li, linux-nfs



On 10/21/22 8:41 AM, Zhi Li wrote:
> In function nfs_parse_square_bracket, hostname could be NULL,
> dereferencing it in free(*hostname) may cause an unexpected segfault.
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2136807
> Signed-off-by: Zhi Li <yieli@redhat.com>
Committed...

steved.
> ---
>   utils/mount/parse_dev.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c
> index 0d3bcb95..2ade5d5d 100644
> --- a/utils/mount/parse_dev.c
> +++ b/utils/mount/parse_dev.c
> @@ -170,7 +170,8 @@ static int nfs_parse_square_bracket(const char *dev,
>   	if (pathname) {
>   		*pathname = strndup(cbrace, path_len);
>   		if (*pathname == NULL) {
> -			free(*hostname);
> +			if (hostname)
> +				free(*hostname);
>   			return nfs_pdn_nomem_err();
>   		}
>   	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-24 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-21 12:41 [PATCH] [nfs/nfs-utils] mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket Zhi Li
2022-10-24 17:37 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).