Skip to content

Be sure to null terminate copied charset string - fixes #34 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
else if (!strcasecmp("b", encoding)) {
/* base64 decoding */
int len;
size_t charsetlen;
#ifdef HAVE_ICONV
size_t tmplen;
char *output2;
Expand All @@ -926,7 +927,9 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
memcpy(output,output2,tmplen);
output += tmplen;
free(output2);
memcpy(charsetsave,charset,strlen(charset)<255 ? strlen(charset) : 255 );
charsetlen = strlen(charset) < 255 ? strlen(charset) : 255;
memcpy(charsetsave,charset,charsetlen);
charsetsave[charsetlen] = '\0';
#else
base64Decode(ptr, output, &len);
output += len;
Expand Down