Skip to content

Memory issues detected by libasan #68

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 3 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
char charset[129];
char encoding[33];
char dummy[129];
char *ptr;
char *ptr, *endptr;
char *old_output;

#ifdef NOTUSED
Expand Down Expand Up @@ -959,6 +959,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)

if (!strcasecmp("q", encoding)) {
/* quoted printable decoding */
endptr = ptr + strlen(ptr);

#ifdef HAVE_ICONV
char *orig2,*output2,*output3;
Expand All @@ -967,7 +968,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
memset(output2,0,strlen(string)+1);
old_output=output;

for (; *ptr; ptr++) {
for (; ptr < endptr; ptr++) {
switch (*ptr) {
case '=':
sscanf(ptr + 1, "%02X", &value);
Expand All @@ -991,7 +992,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
memcpy(charsetsave,charset,charsetlen);
charsetsave[charsetlen] = '\0';
#else
for (; *ptr; ptr++) {
for (; ptr < endptr; ptr++) {
switch (*ptr) {
case '=':
sscanf(ptr + 1, "%02X", &value);
Expand Down Expand Up @@ -2378,6 +2379,7 @@ int parsemail(char *mbox, /* file name */
#endif
if (charset) {
free(charset);
charset = NULL;
}
charsetsave[0] = '\0';

Expand Down
2 changes: 1 addition & 1 deletion src/uudecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int uudecode(FILE *input, /* get file data from (if needed) */
if (init) {
/* search for header line */
/* AUDIT biege: BOF in buf! */
sprintf(scanfstring, "begin %%o %%%us", sizeof(buf));
sprintf(scanfstring, "begin %%o %%%us", sizeof(buf) -1);
while (2 != sscanf(iptr, scanfstring, &mode, buf)) {
if (!fgets(buf, MAXPATHLEN, input)) {
return 2;
Expand Down