mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket
Subsystems (2)
PATCH 1/1 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.
Signed-off-by Zhi Li <[email protected]>
--- utils/mount/parse_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
utils/mount/parse_dev.c +2 -1
@@ -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 (); } }
Signature · 1 line
2.37.3
Quoted 5 lines · Zhi Li
In function
nfs_parse_square_bracket, hostname could be NULL, dereferencing it infree(*hostname)may cause an unexpected segfault.Signed-off-by Zhi Li <[email protected]>
Committed...
steved.
Quoted 18 lines
--- utils/mount/parse_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)utils/mount/parse_dev.c +2
-1@@ -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 (); } }