[PATCH RFC] mountd: Fix check_wildcard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After commit 8f459a072f93 ("Remove abuse of ai_canonname") the
ai_canonname field in addrinfo structs returned from
host_reliable_addrinfo() is always NULL. This causes a segfault in
check_wildcard(), breaking wildcarded client names in
/etc/exports.

The proposed solution is to add a DNS query in check_wildcard() to
obtain the client's canonical hostname on which to perform the
wildcard match.

Note that check_netgroup() probably has the same issue.

Reported-by: Mark Wagner <mark@xxxxxxxxxxx>
Fixes: 8f459a072f93 ("Remove abuse of ai_canonname")
Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---
 support/export/client.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index a1fba01..05260ed 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -608,17 +608,23 @@ check_subnetwork(const nfs_client *clp, const struct addrinfo *ai)
 static int
 check_wildcard(const nfs_client *clp, const struct addrinfo *ai)
 {
-	char *cname = clp->m_hostname;
-	char *hname = ai->ai_canonname;
+	char *hname, *cname = clp->m_hostname;
 	struct hostent *hp;
 	char **ap;
 
-	if (wildmat(hname, cname))
+	hname = host_canonname(ai->ai_addr);
+	if (hname == NULL)
+		return 0;
+
+	if (wildmat(hname, cname)) {
+		free(hname);
 		return 1;
+	}
 
 	/* See if hname aliases listed in /etc/hosts or nis[+]
 	 * match the requested wildcard */
 	hp = gethostbyname(hname);
+	free(hname);
 	if (hp != NULL) {
 		for (ap = hp->h_aliases; *ap; ap++)
 			if (wildmat(*ap, cname))




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux