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!
-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;
 }
 
02-20 17:16:21 -0500'>2022-02-20Clean up unimplemented editing mode stuffJune McEnroe 2022-02-20Save input buffer contentsJune McEnroe 2022-02-20Share a cut buffer between all edit buffersJune McEnroe 2022-02-20Assert return values in edit testsJune McEnroe 2022-02-20Move mbs out of struct Edit, use a global bufferJune McEnroe 2022-02-20Clear edit buffer before running commandJune McEnroe 2022-02-20Show indicator in status when window has pending inputJune McEnroe 2022-02-20Use separate edit buffers for each IDJune McEnroe 2022-02-20Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe 2022-02-18Implement new line editing "library"June McEnroe 2022-02-18Simplify cursor positioning in inputJune McEnroe 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe