diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-07-30 16:44:16 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-07-30 16:44:16 +0200 |
commit | 3b51c5938a82f831c5f734630fdebb165f747ced (patch) | |
tree | c0f62ae9e30481e68c3c1085cc8a7a5c7aa9bbd8 /rfc2047.c | |
parent | 7fd982d172423a47f7310e250b30987f2ac7ec49 (diff) | |
download | mblaze-3b51c5938a82f831c5f734630fdebb165f747ced.tar.gz mblaze-3b51c5938a82f831c5f734630fdebb165f747ced.tar.xz mblaze-3b51c5938a82f831c5f734630fdebb165f747ced.zip |
rfc2047: blaze822_decode_b64: ensure nul-termination of result
Fixes #70.
Diffstat (limited to 'rfc2047.c')
-rw-r--r-- | rfc2047.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rfc2047.c b/rfc2047.c index d0bd103..5f5c2f5 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -75,7 +75,7 @@ blaze822_decode_b64(char *s, char *e, char **deco, size_t *decleno) 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 }; - char *buf = malloc((e - s) / 4 * 3); + char *buf = malloc((e - s) / 4 * 3 + 1); if (!buf) return 0; @@ -118,6 +118,8 @@ error: if (c3 != '=') *buf++ = d2; } + *buf = 0; + *decleno = buf - *deco; return 1; } |