diff options
author | June McEnroe <june@causal.agency> | 2019-12-21 06:35:51 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-12-21 06:35:51 -0500 |
commit | 9059861edf2ba68c5ea356918a0347323c9f0d2b (patch) | |
tree | e945a6127911d1739991c17f9a7ff0148cc64eca | |
parent | Add copy of GPL (diff) | |
download | imbox-9059861edf2ba68c5ea356918a0347323c9f0d2b.tar.gz imbox-9059861edf2ba68c5ea356918a0347323c9f0d2b.zip |
Null-terminate read literals
No wonder there was garbage... Silly mistake!
Diffstat (limited to '')
-rw-r--r-- | imbox.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/imbox.c b/imbox.c index 9f46983..1712615 100644 --- a/imbox.c +++ b/imbox.c @@ -65,8 +65,6 @@ static void mboxrd(const char *headers, const char *body) { ); printf("%s", headers); - // FIXME: There seems to sometimes be some garbage data at the end of the - // headers? static regex_t quoteRegex; compile("eRegex, "^>*From "); @@ -161,12 +159,13 @@ static char *readLiteral(FILE *imap, const char *line) { size_t size = strtoul(prefix + 1, NULL, 10); if (!size) errx(EX_PROTOCOL, "invalid literal size"); - char *literal = malloc(size); + char *literal = malloc(size + 1); if (!literal) err(EX_OSERR, "malloc"); size_t count = fread(literal, size, 1, imap); if (!count) errx(EX_PROTOCOL, "could not read literal"); + literal[size] = '\0'; return literal; } |