cracklib/cracklib-2.9.1-packlib-lookup.patch
2013-12-09 11:38:54 +01:00

106 lines
2.6 KiB
Diff

diff -up cracklib-2.9.1/lib/packer.h.lookup cracklib-2.9.1/lib/packer.h
--- cracklib-2.9.1/lib/packer.h.lookup 2013-12-09 09:52:42.153260712 +0100
+++ cracklib-2.9.1/lib/packer.h 2013-12-09 09:52:42.155260757 +0100
@@ -60,6 +60,7 @@ typedef struct
int count;
char data_put[NUMWORDS][MAXWORDLEN];
char data_get[NUMWORDS][MAXWORDLEN];
+ uint32_t prevblock;
} PWDICT;
#define PW_WORDS(x) ((x)->header.pih_numwords)
diff -up cracklib-2.9.1/lib/packlib.c.lookup cracklib-2.9.1/lib/packlib.c
--- cracklib-2.9.1/lib/packlib.c.lookup 2013-12-03 15:00:15.000000000 +0100
+++ cracklib-2.9.1/lib/packlib.c 2013-12-09 09:53:43.580643470 +0100
@@ -84,6 +84,7 @@ PWOpen(prefix, mode)
memset(&pdesc, '\0', sizeof(pdesc));
memset(&pdesc64, '\0', sizeof(pdesc64));
+ pdesc.prevblock = 0xffffffff;
snprintf(iname, STRINGSIZE, "%s.pwi", prefix);
snprintf(dname, STRINGSIZE, "%s.pwd", prefix);
@@ -446,12 +447,11 @@ GetPW(pwp, number)
register char *nstr;
register char *bptr;
char buffer[NUMWORDS * MAXWORDLEN];
- static uint32_t prevblock = 0xffffffff;
uint32_t thisblock;
thisblock = number / NUMWORDS;
- if (prevblock == thisblock)
+ if (pwp->prevblock == thisblock)
{
#if DEBUG
fprintf(stderr, "returning (%s)\n", pwp->data_get[number % NUMWORDS]);
@@ -526,13 +526,16 @@ GetPW(pwp, number)
return NULL;
}
- prevblock = thisblock;
+ pwp->prevblock = thisblock;
bptr = buffer;
for (ostr = pwp->data_get[0]; (*(ostr++) = *(bptr++)); /* nothing */ );
ostr = pwp->data_get[0];
+#if DEBUG
+ fprintf(stderr, "data_get[0]: %s\n", ostr);
+#endif
for (i = 1; i < NUMWORDS; i++)
{
@@ -543,6 +546,9 @@ GetPW(pwp, number)
while ((*(ostr++) = *(bptr++)));
ostr = nstr;
+#if DEBUG
+ fprintf(stderr, "data_get[%d]: %s\n", i, ostr);
+#endif
}
return (pwp->data_get[number % NUMWORDS]);
@@ -621,22 +627,28 @@ fprintf(stderr, "look for (%s)\n", strin
return(middle);
}
- if (middle == hwm)
- {
-#if DEBUG
- fprintf(stderr, "at terminal subdivision, stopping search\n");
-#endif
- break;
- }
-
if (cmp < 0)
{
- hwm = middle;
- }
+ if (middle == lwm)
+ {
+#if DEBUG
+ fprintf(stderr, "at terminal subdivision from right, stopping search\n");
+#endif
+ break;
+ }
+ hwm = middle - 1;
+ }
else if (cmp > 0)
{
- lwm = middle;
- }
+ if (middle == hwm)
+ {
+#if DEBUG
+ fprintf(stderr, "at terminal subdivision from left, stopping search\n");
+#endif
+ break;
+ }
+ lwm = middle + 1;
+ }
}
return (PW_WORDS(pwp));