forked from github/server
fix off-by-one error
This commit is contained in:
parent
ca6bc638ed
commit
1682b3d583
|
@ -1,3 +1,3 @@
|
|||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 7
|
||||
#define VERSION_BUILD 13
|
||||
#define VERSION_BUILD 14
|
||||
|
|
|
@ -1156,7 +1156,7 @@ void write_spellbook(const struct spellbook *book, struct storage *store)
|
|||
WRITE_TOK(store, "end");
|
||||
}
|
||||
|
||||
char * getpasswd(int fno) {
|
||||
static char * getpasswd(int fno) {
|
||||
const char *prefix = itoa36(fno);
|
||||
size_t len = strlen(prefix);
|
||||
FILE * F = fopen("passwords.txt", "r");
|
||||
|
@ -1165,6 +1165,9 @@ char * getpasswd(int fno) {
|
|||
while (!feof(F)) {
|
||||
fgets(line, sizeof(line), F);
|
||||
if (line[len]==':' && strncmp(prefix, line, len)==0) {
|
||||
size_t slen = strlen(line)-1;
|
||||
assert(line[slen]=='\n');
|
||||
line[slen] = 0;
|
||||
fclose(F);
|
||||
return _strdup(line+len+1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue