Re: dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= S->used' failed

Marius Karthaus <[email protected]>
Newsgroups gmane.mail.imap.dbmail
Organization LowVoice
Message-ID <[email protected]>
Hi All,

I'm encountering the same issue and the problem seems to be the function 
"p_string_erase" in "dm_string.c"

The assertion around line 160 fails because the 'len' is bigger than the 
S->used (pos is always 0 as far as i've seen).

I'm assuming this is because 'len' represents the line-count for the 
operation, and S->used holds the size of the array of parsed lines. My 
guess is malformed messages cause the system to believe there are N 
lines where there are in fact only M lines available in the array. The 
p_string_erase function gets called with a bad / too big argument 'len', 
tests the assertion and just exits (which is a huge over-reaction for 
production code)

Because I did not have time or the means to analyse the true nature of 
the code I've just implemented a dirty workaround and hoped for the 
best, which at this point seems to be working just fine. Untill someone 
comes up with a true fix I suggest replacing the function with this:

T p_string_erase(T S, size_t pos, int len)

	{

	assert(S);

	assert(pos <= S->used);

	// attempted workaround by marius size_t tw=len; if (tw > S->used){ 
fprintf(stderr, "ASSERT WILL NOW CRASH BUT LETS ATTEMPT A WORKAROUND 
[%zu] [%zu] [%u] [%s]\n",S->used,pos,len,S->str); len = S->used; } // 
END OF WORKAROUND

	if (len < 0)

	len = S->used - pos;

	else {

	assert (pos + len <= S->used);

	

	if (pos + len < S->used)

	memmove (S->str + pos, S->str + pos + len, S->used - (pos + len));

	}

	

	S->used -= len;

	

	S->str[S->used] = 0;

	

	return S;

	}



Regards,
Marius Karthaus
BudgetDedicated.com

Op 27-09-15 om 11:50 schreef Reindl Harald:
> that's not funny and leads in multiple crashes and systemd-restart of 
> dbmail-imapd for two days now and it appears to be triggered by 
> specific clients because it was away for many hours and started again 
> in the evening every few minutes
>
> Sep 27 11:09:46 mail systemd: dbmail-imapd.service: main process 
> exited, code=killed, status=6/ABRT
> Sep 27 11:09:46 mail systemd: Unit dbmail-imapd.service entered failed 
> state.
> Sep 27 11:09:46 mail systemd: dbmail-imapd.service failed.
> Sep 27 11:09:47 mail systemd: dbmail-imapd.service holdoff time over, 
> scheduling restart.
> Sep 27 11:09:47 mail systemd: Stopping DBMail IMAP Server...
> Sep 27 11:09:47 mail systemd: Starting DBMail IMAP Server...
> Sep 27 11:09:47 mail systemd: Started DBMail IMAP Server.
> Sep 27 11:10:04 mail systemd: dbmail-imapd.service: main process 
> exited, code=killed, status=6/ABRT
> Sep 27 11:10:04 mail systemd: Unit dbmail-imapd.service entered failed 
> state.
> Sep 27 11:10:04 mail systemd: dbmail-imapd.service failed.
> Sep 27 11:10:05 mail systemd: dbmail-imapd.service holdoff time over, 
> scheduling restart.
> Sep 27 11:10:05 mail systemd: Stopping DBMail IMAP Server...
> Sep 27 11:10:05 mail systemd: Starting DBMail IMAP Server...
> Sep 27 11:10:05 mail systemd: Started DBMail IMAP Server.
> Sep 27 11:12:25 mail systemd: dbmail-imapd.service: main process 
> exited, code=killed, status=6/ABRT
> Sep 27 11:12:25 mail systemd: Unit dbmail-imapd.service entered failed 
> state.
> Sep 27 11:12:25 mail systemd: dbmail-imapd.service failed.
> Sep 27 11:12:26 mail systemd: dbmail-imapd.service holdoff time over, 
> scheduling restart.
> Sep 27 11:12:26 mail systemd: Stopping DBMail IMAP Server...
> Sep 27 11:12:26 mail systemd: Starting DBMail IMAP Server...
> Sep 27 11:12:26 mail systemd: Started DBMail IMAP Server.
>
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
> dbmail-imapd: dm_string.c:161: p_string_erase: Assertion `pos + len <= 
> S->used' failed.
>
>
>
> _______________________________________________
> DBmail mailing list
> [email protected]
> http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.