Skip to content

Commit 53ec94b

Browse files
authored
Merge pull request #68 from bapt/libasan
Memory issues detected by libasan
2 parents 466b358 + d35936e commit 53ec94b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/parse.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
924924
char charset[129];
925925
char encoding[33];
926926
char dummy[129];
927-
char *ptr;
927+
char *ptr, *endptr;
928928
char *old_output;
929929

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

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

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

970-
for (; *ptr; ptr++) {
971+
for (; ptr < endptr; ptr++) {
971972
switch (*ptr) {
972973
case '=':
973974
sscanf(ptr + 1, "%02X", &value);
@@ -991,7 +992,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
991992
memcpy(charsetsave,charset,charsetlen);
992993
charsetsave[charsetlen] = '\0';
993994
#else
994-
for (; *ptr; ptr++) {
995+
for (; ptr < endptr; ptr++) {
995996
switch (*ptr) {
996997
case '=':
997998
sscanf(ptr + 1, "%02X", &value);
@@ -2378,6 +2379,7 @@ int parsemail(char *mbox, /* file name */
23782379
#endif
23792380
if (charset) {
23802381
free(charset);
2382+
charset = NULL;
23812383
}
23822384
charsetsave[0] = '\0';
23832385

src/uudecode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int uudecode(FILE *input, /* get file data from (if needed) */
7575
if (init) {
7676
/* search for header line */
7777
/* AUDIT biege: BOF in buf! */
78-
sprintf(scanfstring, "begin %%o %%%us", sizeof(buf));
78+
sprintf(scanfstring, "begin %%o %%%us", sizeof(buf) -1);
7979
while (2 != sscanf(iptr, scanfstring, &mode, buf)) {
8080
if (!fgets(buf, MAXPATHLEN, input)) {
8181
return 2;

0 commit comments

Comments
 (0)