Accept variable length note names
Read up to the first blank in note_read() instead of assuming a fixed-width note file name. Accept everything up to 40 characters (which is the length of a SHA1 hash in hexadecimal representation). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
17
src/note.c
17
src/note.c
@@ -93,7 +93,18 @@ erase_note (char **note, enum eraseflg flag)
|
||||
void
|
||||
note_read (char *buffer, FILE *fp)
|
||||
{
|
||||
(void)fgets (buffer, NOTESIZ + 1, fp);
|
||||
buffer[NOTESIZ] = '\0';
|
||||
getc (fp);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_NOTESIZ; i++)
|
||||
{
|
||||
buffer[i] = getc (fp);
|
||||
if (buffer[i] == ' ')
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (getc (fp) != ' ');
|
||||
buffer[MAX_NOTESIZ] = '\0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user