about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-21 06:35:51 -0500
committerJune McEnroe <june@causal.agency>2019-12-21 06:35:51 -0500
commit9059861edf2ba68c5ea356918a0347323c9f0d2b (patch)
treee945a6127911d1739991c17f9a7ff0148cc64eca
parentAdd copy of GPL (diff)
downloadimbox-9059861edf2ba68c5ea356918a0347323c9f0d2b.tar.gz
imbox-9059861edf2ba68c5ea356918a0347323c9f0d2b.zip
Null-terminate read literals
No wonder there was garbage... Silly mistake!
Diffstat (limited to '')
-rw-r--r--imbox.c5
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(&quoteRegex, "^>*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;
 }
 
56af3b9e&follow=1'>Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe