On Fri, Feb 27, 2015 at 3:16 PM, Jan Vlach <[email protected]> wrote:
> backtrace from binary with debug symbols enabled follows:
...
> #3 0x1b8c50b8 in nfsnprintf (buf=0xcfbd1920 "1425049063.0_2971E�\211",
> blen=128, fmt=0x3b8bdd71 "%ld.%d_%d.%s")
> at /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/util.c:193
> #4 0x1b8ce4bf in maildir_store_msg (gctx=0x815bd600, data=0xcfbd1a3c,
> uid=0xcfbd1a48)
> at /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_maildir.c:939
Code is wrong:
bl = nfsnprintf( base, sizeof(base), "%ld.%d_%d.%s", time( 0
), Pid, ++MaildirCount, Hostname );
Format string uses %ld but time() returns a time_t, which is now long
long, so this will fail on all ILP32 archs. Should be patched to
bl = nfsnprintf( base, sizeof(base), "%lld.%d_%d.%s", (long
long)time( 0 ), Pid, ++MaildirCount, Hostname );
(The cast makes it work regardless of what the time_t typedef is.)
Line 1089 has another format mismatch:
nfsnprintf( nbuf, sizeof(nbuf),
"%s%s/%s/%ld.%d_%d.%s%s" 1089 , gctx->conf->path, gctx->conf->trash,
subdirs[gmsg->status & M_RECENT], time( 0
), Pid, ++MaildirCount, Hostname, s ? s : "" );
Whole port should be built with -Wformat to catch all such issues.
Philip Guenther