Blame SOURCES/cracklib-2.9.6-cve-2016-6318.patch

017226
diff -up cracklib-2.9.6/lib/fascist.c.overflow cracklib-2.9.6/lib/fascist.c
017226
--- cracklib-2.9.6/lib/fascist.c.overflow	2015-10-23 16:58:38.403319225 +0200
017226
+++ cracklib-2.9.6/lib/fascist.c	2016-12-08 17:28:41.490101358 +0100
017226
@@ -515,7 +515,7 @@ FascistGecosUser(char *password, const c
017226
     char gbuffer[STRINGSIZE];
017226
     char tbuffer[STRINGSIZE];
017226
     char *uwords[STRINGSIZE];
017226
-    char longbuffer[STRINGSIZE * 2];
017226
+    char longbuffer[STRINGSIZE];
017226
 
017226
     if (gecos == NULL)
017226
 	gecos = "";
017226
@@ -596,38 +596,47 @@ FascistGecosUser(char *password, const c
017226
     {
017226
 	for (i = 0; i < j; i++)
017226
 	{
017226
-	    strcpy(longbuffer, uwords[i]);
017226
-	    strcat(longbuffer, uwords[j]);
017226
-
017226
-	    if (GTry(longbuffer, password))
017226
+	    if (strlen(uwords[i]) + strlen(uwords[j]) < STRINGSIZE)
017226
 	    {
017226
-		return _("it is derived from your password entry");
017226
-	    }
017226
-
017226
-	    strcpy(longbuffer, uwords[j]);
017226
-	    strcat(longbuffer, uwords[i]);
017226
+		strcpy(longbuffer, uwords[i]);
017226
+		strcat(longbuffer, uwords[j]);
017226
 
017226
-	    if (GTry(longbuffer, password))
017226
-	    {
017226
-		return _("it's derived from your password entry");
017226
+		if (GTry(longbuffer, password))
017226
+		{
017226
+		    return _("it is derived from your password entry");
017226
+		}
017226
+
017226
+		strcpy(longbuffer, uwords[j]);
017226
+		strcat(longbuffer, uwords[i]);
017226
+
017226
+		if (GTry(longbuffer, password))
017226
+		{
017226
+		   return _("it's derived from your password entry");
017226
+		}
017226
 	    }
017226
 
017226
-	    longbuffer[0] = uwords[i][0];
017226
-	    longbuffer[1] = '\0';
017226
-	    strcat(longbuffer, uwords[j]);
017226
-
017226
-	    if (GTry(longbuffer, password))
017226
+	    if (strlen(uwords[j]) < STRINGSIZE - 1)
017226
 	    {
017226
-		return _("it is derivable from your password entry");
017226
+		longbuffer[0] = uwords[i][0];
017226
+		longbuffer[1] = '\0';
017226
+		strcat(longbuffer, uwords[j]);
017226
+
017226
+		if (GTry(longbuffer, password))
017226
+		{
017226
+		    return _("it is derivable from your password entry");
017226
+		}
017226
 	    }
017226
 
017226
-	    longbuffer[0] = uwords[j][0];
017226
-	    longbuffer[1] = '\0';
017226
-	    strcat(longbuffer, uwords[i]);
017226
-
017226
-	    if (GTry(longbuffer, password))
017226
+	    if (strlen(uwords[i]) < STRINGSIZE - 1)
017226
 	    {
017226
-		return _("it's derivable from your password entry");
017226
+		longbuffer[0] = uwords[j][0];
017226
+		longbuffer[1] = '\0';
017226
+		strcat(longbuffer, uwords[i]);
017226
+
017226
+		if (GTry(longbuffer, password))
017226
+		{
017226
+		    return _("it's derivable from your password entry");
017226
+		}
017226
 	    }
017226
 	}
017226
     }
017226
diff -up cracklib-2.9.6/lib/rules.c.overflow cracklib-2.9.6/lib/rules.c
017226
--- cracklib-2.9.6/lib/rules.c.overflow	2015-10-23 16:58:38.000000000 +0200
017226
+++ cracklib-2.9.6/lib/rules.c	2016-12-08 18:03:27.041941297 +0100
017226
@@ -158,6 +158,8 @@ Pluralise(string, area)		/* returns a po
017226
     register int length;
017226
     length = strlen(string);
017226
     strcpy(area, string);
017226
+    if (length > STRINGSIZE - 3) /* we add 2 characters at worst */
017226
+	return (area);
017226
 
017226
     if (!Suffix(string, "ch") ||
017226
 	!Suffix(string, "ex") ||
017226
@@ -462,11 +464,11 @@ Mangle(input, control, area)		/* returns
017226
 	    Pluralise(area2, area);
017226
 	    break;
017226
 	case RULE_REFLECT:
017226
-	    strcat(area, Reverse(area, area2));
017226
+	    strncat(area, Reverse(area, area2), STRINGSIZE - strlen(area) - 1);
017226
 	    break;
017226
 	case RULE_DUPLICATE:
017226
 	    strcpy(area2, area);
017226
-	    strcat(area, area2);
017226
+	    strncat(area, area2, STRINGSIZE - strlen(area) - 1);
017226
 	    break;
017226
 	case RULE_GT:
017226
 	    if (!ptr[1])
017226
@@ -514,7 +516,8 @@ Mangle(input, control, area)		/* returns
017226
 	    } else
017226
 	    {
017226
 		area2[0] = *(++ptr);
017226
-		strcpy(area2 + 1, area);
017226
+		strncpy(area2 + 1, area, STRINGSIZE - 2);
017226
+		area2[STRINGSIZE - 1] = '\0';
017226
 		strcpy(area, area2);
017226
 	    }
017226
 	    break;
017226
@@ -528,8 +531,10 @@ Mangle(input, control, area)		/* returns
017226
 		register char *string;
017226
 		string = area;
017226
 		while (*(string++));
017226
-		string[-1] = *(++ptr);
017226
-		*string = '\0';
017226
+		if (string < area + STRINGSIZE) {
017226
+			string[-1] = *(++ptr);
017226
+			*string = '\0';
017226
+		}
017226
 	    }
017226
 	    break;
017226
 	case RULE_EXTRACT:
017226
@@ -600,6 +605,10 @@ Mangle(input, control, area)		/* returns
017226
 		}
017226
 		p1 = area;
017226
 		p2 = area2;
017226
+		if (strlen(p1) > STRINGSIZE - 2) {
017226
+			/* truncate */
017226
+			p1[STRINGSIZE - 2] = '\0';
017226
+		}
017226
 		while (i && *p1)
017226
 		{
017226
 		    i--;