Browse Source

nfs-kernel-server: fix freeaddrinfo usage in nfs-kernel-server, because freeaddrinfo in musl after the 1.1.21

update, doesn't handly NULL pointers (which seems to spec conform) see
https://www.openwall.com/lists/musl/2019/02/03/3 for more info

Signed-off-by: Peter Wagner <tripolar@gmx.at>
lilik-openwrt-22.03
Peter Wagner 6 years ago
parent
commit
274ce493eb
3 changed files with 126 additions and 3 deletions
  1. +2
    -2
      net/nfs-kernel-server/Makefile
  2. +5
    -1
      net/nfs-kernel-server/files/nfsd.init
  3. +119
    -0
      net/nfs-kernel-server/patches/000-freeaddrinfo.patch

+ 2
- 2
net/nfs-kernel-server/Makefile View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nfs-kernel-server
PKG_VERSION:=2.3.3
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_HASH:=3c8c63611c7e78b7a3b2f8a28b9928a5b5e66d5e9ad09a1e54681508884320a4
PKG_SOURCE_URL:=@SF/nfs
@ -197,7 +197,7 @@ endef
define Package/nfs-utils-libs/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnfsidmap.so* $(1)/usr/lib/
$(if $(CONFIG_NFS_KERNEL_SERVER_V4),$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnfsidmap.so* $(1)/usr/lib/,)
endef
$(eval $(call HostBuild))


+ 5
- 1
net/nfs-kernel-server/files/nfsd.init View File

@ -9,6 +9,7 @@ USE_PROCD=1
NFS_D=/var/lib/nfs
RECOVERY_D=$NFS_D/v4recovery
LOCK_D=/var/lib/nfs/sm
VAR_NFS=/var/lib/nfs
start_service() {
grep -q /proc/fs/nfsd /proc/mounts || \
@ -18,6 +19,9 @@ start_service() {
mkdir -p $LOCK_D
touch $NFS_D/rmtab
mkdir -p $VAR_NFS
chown nfs:nfs $VAR_NFS
sysctl -w fs.nfs.nlm_tcpport=32777 fs.nfs.nlm_udpport=32777 > /dev/null
procd_open_instance
@ -25,7 +29,7 @@ start_service() {
procd_close_instance
/usr/sbin/exportfs -r
/usr/sbin/rpc.nfsd
/usr/sbin/rpc.nfsd --grace-time 10
procd_open_instance
procd_set_param command /usr/sbin/rpc.mountd -p 32780 -F


+ 119
- 0
net/nfs-kernel-server/patches/000-freeaddrinfo.patch View File

@ -0,0 +1,119 @@
diff --git a/support/export/client.c b/support/export/client.c
index baf59c8..750eb7d 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -309,7 +309,8 @@ client_lookup(char *hname, int canonical)
init_addrlist(clp, ai);
out:
- freeaddrinfo(ai);
+ if (ai)
+ freeaddrinfo(ai);
return clp;
}
diff --git a/support/export/hostname.c b/support/export/hostname.c
index 5c4c824..710bf61 100644
--- a/support/export/hostname.c
+++ b/support/export/hostname.c
@@ -354,7 +354,7 @@ host_numeric_addrinfo(const struct sockaddr *sap)
* getaddrinfo(AI_NUMERICHOST) never fills in ai_canonname
*/
if (ai != NULL) {
- free(ai->ai_canonname); /* just in case */
+ //free(ai->ai_canonname); /* just in case */
ai->ai_canonname = strdup(buf);
if (ai->ai_canonname == NULL) {
freeaddrinfo(ai);
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index cd3c979..2f8d59a 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -282,7 +282,8 @@ exportfs_parsed(char *hname, char *path, char *options, int verbose)
validate_export(exp);
out:
- freeaddrinfo(ai);
+ if (ai)
+ freeaddrinfo(ai);
}
static int exportfs_generic(char *arg, char *options, int verbose)
@@ -395,7 +396,8 @@ unexportfs_parsed(char *hname, char *path, int verbose)
if (!success)
xlog(L_ERROR, "Could not find '%s:%s' to unexport.", hname, path);
- freeaddrinfo(ai);
+ if (ai)
+ freeaddrinfo(ai);
}
static int unexportfs_generic(char *arg, int verbose)
@@ -639,8 +641,10 @@ matchhostname(const char *hostname1, const char *hostname2)
}
out:
- freeaddrinfo(results1);
- freeaddrinfo(results2);
+ if (results1)
+ freeaddrinfo(results1);
+ if (results2)
+ freeaddrinfo(results2);
return result;
}
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 4d2e37e..612ef1e 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -1263,7 +1263,8 @@ int nfsmount_string(const char *spec, const char *node, char *type,
} else
nfs_error(_("%s: internal option parsing error"), progname);
- freeaddrinfo(mi.address);
+ if (mi.address)
+ freeaddrinfo(mi.address);
free(mi.hostname);
return retval;
}
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 6f42512..18a5d9e 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -834,7 +834,8 @@ static void nfsd_fh(int f)
out:
if (found_path)
free(found_path);
- freeaddrinfo(ai);
+ if(ai)
+ freeaddrinfo(ai);
free(dom);
xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL);
}
@@ -1355,7 +1356,8 @@ static void nfsd_export(int f)
xlog(D_CALL, "nfsd_export: found %p path %s", found, path ? path : NULL);
if (dom) free(dom);
if (path) free(path);
- freeaddrinfo(ai);
+ if (ai)
+ freeaddrinfo(ai);
}
diff --git a/utils/statd/hostname.c b/utils/statd/hostname.c
index 8cccdb8..6556ab1 100644
--- a/utils/statd/hostname.c
+++ b/utils/statd/hostname.c
@@ -308,8 +308,10 @@ statd_matchhostname(const char *hostname1, const char *hostname2)
}
out:
- freeaddrinfo(results2);
- freeaddrinfo(results1);
+ if (results2)
+ freeaddrinfo(results2);
+ if (results1)
+ freeaddrinfo(results1);
xlog(D_CALL, "%s: hostnames %s and %s %s", __func__,
hostname1, hostname2,

Loading…
Cancel
Save