$NetBSD: patch-ac,v 1.2 2001/02/28 15:44:16 wiz Exp $ --- src/readsfv.c.orig Fri Dec 29 01:34:33 2000 +++ src/readsfv.c Wed Feb 28 15:25:54 2001 @@ -34,11 +34,12 @@ int find_file(char*, char*); extern int quiet; -int readsfv(char *fn, char *dir, int nocase) +int readsfv(char *fn, char *dir, int nocase, int argc, char **argv) { FILE *fd; char buf[512], *end, filename[512], crc[9], path[256]; int file, rval = 0; + int i, check; unsigned long len, val, sfvcrc; if (quiet == 0) { @@ -63,7 +64,7 @@ if (buf[0] != ';' && buf[0] != '\n' && buf[0] != '\r') { /* build filename and crc from the sfv file */ end = strrchr(buf, ' '); - if (end == NULL) { + if (end == NULL || end-buf > 512-10) { fprintf(stderr, "cksfv: %s: incorrect sfv file format\n", fn); exit(1); } @@ -71,7 +72,24 @@ *(end+9) = '\0'; strncpy(crc, ++end, 9); strncpy(filename, buf, 512); - sfvcrc = strtoul(crc, '\0', 16); + sfvcrc = strtoul(crc, NULL, 16); + + if (argc) { + check = 0; + for (i=0; id_name); } - rewinddir(dirp); + closedir(dirp); return 1;