arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1216246.patch

147e83
commit 8b59c73386ddb64331ee03c29925a18dae547733
147e83
Author: Carlos O'Donell <carlos@systemhalted.org>
147e83
Date:   Wed Jul 8 02:42:11 2015 -0400
147e83
147e83
    Fix ruserok scalability with large ~/.rhosts file.
147e83
    
147e83
    Fixes bug 18557.
147e83
147e83
diff --git glibc-2.17-c758a686/inet/rcmd.c glibc-2.17-c758a686/inet/rcmd.c
147e83
index 98b3735..91623b0 100644
147e83
--- glibc-2.17-c758a686/inet/rcmd.c
147e83
+++ glibc-2.17-c758a686/inet/rcmd.c
147e83
@@ -809,29 +809,38 @@ __validuser2_sa(hostf, ra, ralen, luser, ruser, rhost)
147e83
 	*p = '\0';              /* <nul> terminate username (+host?) */
147e83
 
147e83
 	/* buf -> host(?) ; user -> username(?) */
147e83
+	if (*buf == '\0')
147e83
+	  break;
147e83
+	if (*user == '\0')
147e83
+	  user = luser;
147e83
+
147e83
+	/* First check the user part.  This is an optimization, since
147e83
+	   one should always check the host first in order to detect
147e83
+	   negative host checks (which we check for later).  */
147e83
+	ucheck = __icheckuser (user, ruser);
147e83
+
147e83
+	/* Either we found the user, or we didn't and this is a
147e83
+	   negative host check.  We must do the negative host lookup
147e83
+	   in order to preserve the semantics of stopping on this line
147e83
+	   before processing others.  */
147e83
+	if (ucheck != 0 || *buf == '-') {
147e83
+
147e83
+	    /* Next check host part */
147e83
+	    hcheck = __checkhost_sa (ra, ralen, buf, rhost);
147e83
+
147e83
+	    /* Negative '-host user(?)' match?  */
147e83
+	    if (hcheck < 0)
147e83
+		break;
147e83
 
147e83
-	/* First check host part */
147e83
-	hcheck = __checkhost_sa (ra, ralen, buf, rhost);
147e83
-
147e83
-	if (hcheck < 0)
147e83
-	    break;
147e83
-
147e83
-	if (hcheck) {
147e83
-	    /* Then check user part */
147e83
-	    if (! (*user))
147e83
-		user = luser;
147e83
-
147e83
-	    ucheck = __icheckuser (user, ruser);
147e83
-
147e83
-	    /* Positive 'host user' match? */
147e83
-	    if (ucheck > 0) {
147e83
+	    /* Positive 'host user' match?  */
147e83
+	    if (hcheck > 0 && ucheck > 0) {
147e83
 		retval = 0;
147e83
 		break;
147e83
 	    }
147e83
 
147e83
-	    /* Negative 'host -user' match? */
147e83
-	    if (ucheck < 0)
147e83
-		break;
147e83
+	    /* Negative 'host -user' match?  */
147e83
+	    if (hcheck > 0 && ucheck < 0)
147e83
+	      break;
147e83
 
147e83
 	    /* Neither, go on looking for match */
147e83
 	}