From 63be7eff368135f5200f9f49c78a046f4266865d Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Mon, 14 Nov 2022 15:26:05 -0500 Subject: [PATCH] mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket (bz 2136807) Signed-off-by: Steve Dickson Resolves: bz2136807 --- nfs-utils-2.5.4-mount-null-ptr.patch | 27 +++++++++++++++++++++++++++ nfs-utils.spec | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 nfs-utils-2.5.4-mount-null-ptr.patch diff --git a/nfs-utils-2.5.4-mount-null-ptr.patch b/nfs-utils-2.5.4-mount-null-ptr.patch new file mode 100644 index 0000000..1143018 --- /dev/null +++ b/nfs-utils-2.5.4-mount-null-ptr.patch @@ -0,0 +1,27 @@ +commit ea536a2e641664c8ea439e5e571e757785f587c9 +Author: Zhi Li +Date: Mon Oct 24 13:31:41 2022 -0400 + + 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 + Signed-off-by: Steve Dickson + +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(); + } + } diff --git a/nfs-utils.spec b/nfs-utils.spec index e795bec..a7d728a 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -38,6 +38,7 @@ Patch012: nfs-utils-2.5.4-systemd-rpcstatd.patch # RHEL9.2 # Patch013: nfs-utils-2.5.4-nfsd-man-4vers.patch +Patch014: nfs-utils-2.5.4-mount-null-ptr.patch Patch100: nfs-utils-1.2.1-statdpath-man.patch Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch @@ -473,6 +474,7 @@ fi %changelog * Mon Nov 14 2022 Steve Dickson 2.5.4-16 - nfsd.man: Explain that setting nfsv4=n turns off all v4 versions (bz 2042362) +- mount.nfs: fix NULL pointer derefernce in nfs_parse_square_bracket (bz 2136807) * Thu Aug 18 2022 Steve Dickson 2.5.4-15 - Fix uninstall warnings (bz 2048023)