Skip to content

Commit

Permalink
workaround glib bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pjstevns committed Jun 15, 2014
1 parent 8315fff commit 36aa201
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/dm_message.c
Expand Up @@ -359,9 +359,9 @@ static bool simple_boundary(const char *s, char *boundary)
static bool wrapped_boundary(const char *s, char *boundary)
{
int i = 0;
char *match;
int decimal = 0;
size_t buflen = MAX_MIME_BLEN-1;
size_t buflen = strlen(s);
char match[128];
s += 11; // jump past 'boundary*0='
while (true) {
bool wantquote = false;
Expand All @@ -383,18 +383,21 @@ static bool wrapped_boundary(const char *s, char *boundary)

buflen -= i;
decimal++;
match = g_strdup_printf("boundary*%d=", decimal);

TRACE(TRACE_DEBUG, "search [%s]", &s[i]);
memset(match, 0, sizeof(match));
snprintf(match, sizeof(match)-1, "boundary*%d=", decimal);
TRACE(TRACE_DEBUG, "search [%s]", &s[i]);

TRACE(TRACE_DEBUG, "search [%s] for [%s]", &s[i], match);
s = g_strcasestr(&s[i], match);
TRACE(TRACE_DEBUG, "search: [%s]", s);
if (! s) {
g_free(match);
break;
}

s += strlen(match);
i = 0;
g_free(match);

if (! s[i])
break;
Expand Down
3 changes: 2 additions & 1 deletion test/check_dbmail.h
Expand Up @@ -1569,7 +1569,8 @@ char *multipart_message9 = "From: test\n"
"Date: Fri, 23 May 2014 17:09:58 +0200 (CEST)\n"
"Mime-Version: 1.0\n"
"Content-Type: multipart/alternative;\n"
" boundary=\"=_5be2c88172b006282613c491=0e67d269-8f6d-5f77-bc5a-dedf278583d6_=\"\n"
"\tboundary*0=\"=_5be2c88172b006282613c4916282613c491=0e67d269-8f6d-5f77-bc5a-dedf278583d\";\n"
"\tboundary*1=\"6_=\"\n"
"\n"
"\n"
"--=_5be2c88172b006282613c491=0e67d269-8f6d-5f77-bc5a-dedf278583d6_=\n"
Expand Down

0 comments on commit 36aa201

Please sign in to comment.