about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-04-03 22:46:35 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-04-03 22:46:35 +0200
commite56f8ad294d269bcb918c15168bf7b0c4f858fb4 (patch)
treec8a68833ddfb8b58bbb6be63f652cf986c2c8796
parent3370fd5f705987aa92e613ee914d613ffa247e2c (diff)
downloadmblaze-e56f8ad294d269bcb918c15168bf7b0c4f858fb4.tar.gz
mblaze-e56f8ad294d269bcb918c15168bf7b0c4f858fb4.tar.xz
mblaze-e56f8ad294d269bcb918c15168bf7b0c4f858fb4.zip
blaze822: blaze822_addr: null-terminate ttok at the current position before appending
-rw-r--r--blaze822.c1
-rwxr-xr-xt/1501-maddr-regress.t5
2 files changed, 5 insertions, 1 deletions
diff --git a/blaze822.c b/blaze822.c
index 0434d89..d34a4ae 100644
--- a/blaze822.c
+++ b/blaze822.c
@@ -277,6 +277,7 @@ blaze822_addr(char *s, char **dispo, char **addro)
 			if (memchr(tok, '@', c - tok))
 				not_addr = 1;  // @ inside "" is never an addr
 
+			*tc = 0;
 			tc += safe_append(ttok, sizeof ttok, tok, c);
 		} else if (*s == '(') {
 			char *z = skip_comment(s);
diff --git a/t/1501-maddr-regress.t b/t/1501-maddr-regress.t
index 37b592a..4e6be77 100755
--- a/t/1501-maddr-regress.t
+++ b/t/1501-maddr-regress.t
@@ -1,7 +1,7 @@
 #!/bin/sh
 cd ${0%/*}
 . ./lib.sh
-plan 31
+plan 33
 
 check_addr() {
   printf "From: %s\n" "$1" | check_test "parse $1" = "$2" "maddr /dev/stdin"
@@ -46,3 +46,6 @@ check_addr 'test."test"@example.org' 'test.test@example.org'
 check_addr '<test."test"@example.org>' 'test.test@example.org'
 check_addr 'test"test"@example.org' 'testtest@example.org'
 check_addr '<test"test"@example.org>' 'testtest@example.org'
+
+check_addr 'foo<bar@example.org>' 'foo <bar@example.org>'
+check_addr 'xxxxxxxxx a"test"@example.org' "xxxxxxxxx <atest@example.org>"