aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-12-05 18:05:36 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-12-05 18:05:58 +0100
commit4fef01ab6d24145cb9ecd5d779b90a15764f02cc (patch)
tree2a25fbe5896e56b5c607c51710691db830363fda
parentba4a0cf589d4465d5217cc24b4d3dd0857f6cb0e (diff)
downloadmblaze-4fef01ab6d24145cb9ecd5d779b90a15764f02cc.tar.gz
rfc2047: blaze822_decode_rfc2047: check for NUL bytes at the very end of decoding
-rw-r--r--rfc2047.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/rfc2047.c b/rfc2047.c
index ab65772..1cfec5c 100644
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -130,6 +130,9 @@ blaze822_decode_rfc2047(char *dst, char *src, size_t dlen, char *tgtenc)
iconv_t ic = (iconv_t)-1;
char *srcenc = 0;
+ char *startdst = dst;
+ size_t startdlen = dlen;
+
char *b = src;
// XXX use memmem
@@ -233,9 +236,6 @@ blaze822_decode_rfc2047(char *dst, char *src, size_t dlen, char *tgtenc)
}
}
- if (memchr(dst, 0, dlen))
- goto nocode;
-
while (!partial && declen && dlen) {
*dst++ = *dec++;
declen--;
@@ -252,6 +252,12 @@ blaze822_decode_rfc2047(char *dst, char *src, size_t dlen, char *tgtenc)
dlen--;
}
+ if (memchr(startdst, 0, dst - startdst)) {
+ dst = startdst;
+ dlen = startdlen;
+ goto nocodeok;
+ }
+
*dst = 0;
if (ic != (iconv_t)-1)