/*
* Modified as part of the krb5-strength project as follows:
*
- * 2007-03-23 Russ Allbery <rra@stanford.edu>
+ * 2007-03-23 Russ Allbery <eagle@eyrie.org>
* - Apply Debian patch to improve the search logic.
* - Don't crash if the dictionary is corrupt.
* - Additional system includes for other functions.
- * 2009-10-14 Russ Allbery <rra@stanford.edu>
+ * 2009-10-14 Russ Allbery <eagle@eyrie.org>
* - Add ANSI C protototypes for all functions.
* - Tweaks for const cleanliness.
* - Add parentheses around assignment used for its truth value.
* - Make internal functions static.
* - Remove unused variables.
- * 2009-11-18 Russ Allbery <rra@stanford.edu>
+ * 2009-11-18 Russ Allbery <eagle@eyrie.org>
* - Fixed the data format output by packer to properly pad the end.
+ * 2013-09-24 Russ Allbery <eagle@eyrie.org>
+ * - Add a missing ANSI C prototype.
+ * - Remove last block optimization in GetPW and start fresh each time.
+ * 2013-12-13 Russ Allbery <eagle@eyrie.org>
+ * - Close the wfp file handle on PWClose if it's open.
+ * 2016-11-06 Russ Allbery <eagle@eyrie.org>
+ * - Remove unused vers_id to silence GCC warnings.
+ * 2020-05-16 Russ Allbery <eagle@eyrie.org>
+ * - Fix types of printf formatting directives in DEBUG conditionals.
*/
#include <stdio.h>
#include "packer.h"
-static const char vers_id[] = "packlib.c : v2.3p2 Alec Muffett 18 May 1993";
-
PWDICT *
PWOpen(const char *prefix, const char *mode)
{
pdesc.header.pih_magic = 0;
fclose(ifp);
fclose(dfp);
+ if (wfp != NULL)
+ {
+ fclose(wfp);
+ }
return ((PWDICT *) 0);
}
pdesc.header.pih_magic = 0;
fclose(ifp);
fclose(dfp);
+ if (wfp != NULL)
+ {
+ fclose(wfp);
+ }
return ((PWDICT *) 0);
}
pdesc.header.pih_magic = 0;
fclose(ifp);
fclose(dfp);
+ if (wfp != NULL)
+ {
+ fclose(wfp);
+ }
return ((PWDICT *) 0);
}
}
int
-PWClose(pwp)
- PWDICT *pwp;
+PWClose(PWDICT *pwp)
{
if (pwp->header.pih_magic != PIH_MAGIC)
{
pwp->hwms[i] = pwp->hwms[i-1];
}
#ifdef DEBUG
- printf("hwm[%02x] = %d\n", i, pwp->hwms[i]);
+ printf("hwm[%02x] = %u\n", i, pwp->hwms[i]);
#endif
}
fwrite(pwp->hwms, 1, sizeof(pwp->hwms), pwp->wfp);
fclose(pwp->ifp);
fclose(pwp->dfp);
+ if (pwp->wfp != NULL)
+ {
+ fclose(pwp->wfp);
+ }
pwp->header.pih_magic = 0;
register char *bptr;
char buffer[NUMWORDS * MAXWORDLEN];
static char data[NUMWORDS][MAXWORDLEN];
- static int32 prevblock = 0xffffffff;
int32 thisblock;
thisblock = number / NUMWORDS;
- if (prevblock == thisblock)
- {
- return (data[number % NUMWORDS]);
- }
-
if (fseek(pwp->ifp, sizeof(struct pi_header) + (thisblock * sizeof(int32)), 0))
{
perror("(index fseek failed)");
return ((char *) 0);
}
- prevblock = thisblock;
-
bptr = buffer;
for (ostr = data[0]; (*(ostr++) = *(bptr++)) != '\0'; /* nothing */ );
}
#ifdef DEBUG
- printf("---- %lu, %lu ----\n", lwm, hwm);
+ printf("---- %u, %u ----\n", lwm, hwm);
#endif
for (;;)
int cmp;
#ifdef DEBUG
- printf("%lu, %lu\n", lwm, hwm);
+ printf("%u, %u\n", lwm, hwm);
#endif
middle = lwm + ((hwm - lwm + 1) / 2);