Skip to content

Commit

Permalink
Fix some off-by-one segfaults in keystat.
Browse files Browse the repository at this point in the history
This code is from before my time and I don't exactly understand it,
but the intended usage is apparently

    make emit_keys keystat
    ./emit_keys /usr/share/dict/words > words.keys
    ./keystats words.keys
  • Loading branch information
Quuxplusone committed Apr 22, 2017
1 parent b2ebde3 commit 518a9dc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/keystat.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ int main(int argc, char *argv[])
percent = atoi(argv[2]);
v = 3;
}
if ((argc >= v) && (strcmp(argv[v],"-v") == 0)) {
if ((v < argc) && (strcmp(argv[v],"-v") == 0)) {
verbose=1;
v++;
}
if (argc >= v) {
if (v < argc) {
filename=argv[v];
}
fd=open(filename,MODE);
Expand Down Expand Up @@ -253,4 +253,3 @@ int main(int argc, char *argv[])
}
return 0;
}

0 comments on commit 518a9dc

Please sign in to comment.