about summary refs log tree commit diff
diff options
context:
space:
mode:
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;
 }