Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: fix home directory expansion with NIS



This has been irritating me for a while: some ~username expansions were
coming out as garbled strings from the middle of the password file.

The problem, which is specific to NIS on Solaris, occurs because our
yp_all callback was assuming that the key and val parameters are null
terminated. The fix below makes use of the vallen parameter to find the
end of the string.

Oliver

--- hashtable.c.orig	Thu Nov  1 10:59:22 2007
+++ hashtable.c	Thu Nov  1 11:00:34 2007
@@ -1258,7 +1258,8 @@
 
     if (vallen > keylen && *(p = val + keylen) == ':') {
 	*p++ = '\0';
-	if ((de = strrchr(p, ':'))) {
+	for (de = val + vallen - 1; *de != ':' && de > val; de--);
+	if (de > val) {
 	    *de = '\0';
 	    if ((d = strrchr(p, ':'))) {
 		if (*++d && val[0])



Messages sorted by: Reverse Date, Date, Thread, Author