Re: [Exim] Re: [SA-exim] local_scan is crashing (log_write c…

Pàgina inicial
Delete this message
Reply to this message
Autor: Adam D. Barratt
Data:  
A: Brian Kendig
CC: Marc MERLIN, Exim-users
Assumpte: Re: [Exim] Re: [SA-exim] local_scan is crashing (log_write crash)
On Fri, 2004-05-21 at 19:28, Brian Kendig wrote:
> On May 20, 2004, at 2:11 PM, Adam D. Barratt wrote:

[..]
> > log_write(0, LOG_MAIN, "SA: Action: check skipped due to message size
> > (%.0f bytes) and SATruncBodyCond expanded to false (Message-Id: %s).
> > %s", fdsize-18, safemesgid, mailinfo);
> >
> > with similar replacements for any other occasions on which
> > printf(off_t)
> > occurs.
>
> That did the trick, thank you very much! I changed this line, as well
> as two debug lines I found which try to print fdsize-18.


It should probably be (double)(fdsize - 18) so that it still works on
platforms where sizeof(off_t) != 8 (i.e. most of them *g*).

> Why does this fix work? I figure "%.0f" means a floating-point value
> with no decimal places, but why does displaying the number as a float
> instead of a decimal solve the problem?


"%%d" *isn't* (just) "a decimal", it's a synonym for "%i", and thus an
/int/. On many (probably still most) platforms, sizeof(int) ==
sizeof(off_t), so it works fine. When off_t is larger, however, problems
appear - the reason the original code crashes is that you're passing
four more bytes into log_write() than the format string has led it to
expect. The end result is that the stack space allocated is four bytes
smaller than it should be; whether that causes a crash, or just
unexpected behaviour, rather depends what's using the memory that the
extra four bytes hijack.

Anyway, this is getting a tad OT for exim-users... :)

Regards,

Adam