diff options
author | Zhi Li <yieli@redhat.com> | 2022-10-24 13:31:41 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2022-10-24 13:35:52 -0400 |
commit | ea536a2e641664c8ea439e5e571e757785f587c9 (patch) | |
tree | ef83916d55a80e1d1c2bd3d07809aa8259c4edf5 | |
parent | c1c35487aba2cec828d9b8a1be9043000beadea5 (diff) | |
download | nfs-utils-ea536a2e641664c8ea439e5e571e757785f587c9.tar.gz |
mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket
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>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | utils/mount/parse_dev.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c index 0d3bcb9..2ade5d5 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(); } } |