Hello Philip, David, misc,

mbsync now works and finishes the sync successfully.

I've compiled with -Wformat and it during build it produces some
warnings about strlcpy(), strlcat(), sprintf(), rand() ... full build
log follows.

Also, the patch with your two fixes is attached. I don't know enough to
make this nice to apply only on 32-bit archs ...

Should I contact the maintaner i.e. port@ list (according to
http://openports.se/search.php?so=isync) ?

Thank you again very much for your help and time
Jan Vlach

######
# BUILD LOG
######
===>  Verifying specs:  c crypto ssl lib/db4/db>=4
===>  found c.78.1 crypto.32.0 ssl.32.0 lib/db4/db.5.0
===>  Checking files for isync-1.0.6
`/usr/ports/distfiles/isync-1.0.6.tar.gz' is up to date.
>> (SHA256) isync-1.0.6.tar.gz: OK
===>  Extracting for isync-1.0.6
===>  Patching for isync-1.0.6
===>  Configuring for isync-1.0.6
Using /usr/ports/pobj/isync-1.0.6/config.site (generated)
configure: WARNING: unrecognized options: --disable-silent-rules, 
--disable-gtk-doc
configure: loading site script /usr/ports/pobj/isync-1.0.6/config.site
checking for a BSD-compatible install... 
/usr/ports/pobj/isync-1.0.6/bin/install -c 
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... mkdir -p
checking for gawk... (cached) awk
checking whether make sets $(MAKE)... (cached) yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for style of include used by make... GNU
checking for gcc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... (cached) o
checking whether we are using the GNU C compiler... (cached) yes
checking whether cc accepts -g... (cached) yes
checking for cc option to accept ISO C89... none needed
checking dependency style of cc... gcc3
checking how to run the C preprocessor... cc -E
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... (cached) /usr/bin/egrep
checking for ANSI C header files... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for memory.h... (cached) yes
checking for strings.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/filio.h... (cached) yes
checking for vasprintf... (cached) yes
checking for socket in -lsocket... no
checking for inet_ntoa in -lnsl... no
checking for pkg-config... /usr/bin/pkg-config
checking OpenSSL presence with pkg-config... found
checking for openssl/ssl.h... (cached) yes
checking for Berkley DB 4.2... yes
checking for getopt_long... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/compat/Makefile
config.status: creating isync.spec
config.status: creating config.h
config.status: executing depfiles commands
configure: WARNING: unrecognized options: --disable-silent-rules, 
--disable-gtk-doc

Using SSL

===>  Building for isync-1.0.6
make  all-recursive
Making all in src
Making all in compat
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat 
-I../..    -I/usr/include  -O2 -pipe -ggdb -O0  -Wformat 
-I/usr/local/include/db4 -pipe -W -Wall -Wshadow -Wstrict-prototypes -MT main.o 
-MD -MP -MF .deps/main.Tpo -c -o main.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/main.c
mv -f .deps/main.Tpo .deps/main.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat 
-I../..    -I/usr/include  -O2 -pipe -ggdb -O0  -Wformat 
-I/usr/local/include/db4 -pipe -W -Wall -Wshadow -Wstrict-prototypes -MT 
config.o -MD -MP -MF .deps/config.Tpo -c -o config.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/config.c
mv -f .deps/config.Tpo .deps/config.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat 
-I../..    -I/usr/include  -O2 -pipe -ggdb -O0  -Wformat 
-I/usr/local/include/db4 -pipe -W -Wall -Wshadow -Wstrict-prototypes -MT 
convert.o -MD -MP -MF .deps/convert.Tpo -c -o convert.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/convert.c
mv -f .deps/convert.Tpo .deps/convert.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat 
-I../..    -I/usr/include  -O2 -pipe -ggdb -O0  -Wformat 
-I/usr/local/include/db4 -pipe -W -Wall -Wshadow -Wstrict-prototypes -MT util.o 
-MD -MP -MF .deps/util.Tpo -c -o util.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/util.c
mv -f .deps/util.Tpo .deps/util.Po
cc  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W -Wall 
-Wshadow -Wstrict-prototypes  -L/usr/local/lib/db4 -L/usr/lib -o isync main.o 
config.o convert.o  util.o -ldb 
main.o(.text+0xe72): In function `main':
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/main.c:381: warning: 
strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/db4/libdb.so.5.0: warning: rand() may return deterministic 
values, is that what you want?
main.o(.text+0x10c8):/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/main.c:415:
 warning: strcat() is almost always misused, please use strlcat()
config.o(.text+0x1083): In function `write_imap_server':
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/compat/config.c:263: warning: 
sprintf() is often misused, please use snprintf()
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT main.o -MD -MP -MF .deps/main.Tpo -c -o 
main.o /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/main.c
mv -f .deps/main.Tpo .deps/main.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT sync.o -MD -MP -MF .deps/sync.Tpo -c -o 
sync.o /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/sync.c
mv -f .deps/sync.Tpo .deps/sync.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT config.o -MD -MP -MF .deps/config.Tpo -c 
-o config.o /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/config.c
mv -f .deps/config.Tpo .deps/config.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT util.o -MD -MP -MF .deps/util.Tpo -c -o 
util.o /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/util.c
mv -f .deps/util.Tpo .deps/util.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT drv_imap.o -MD -MP -MF 
.deps/drv_imap.Tpo -c -o drv_imap.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_imap.c
mv -f .deps/drv_imap.Tpo .deps/drv_imap.Po
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT drv_maildir.o -MD -MP -MF 
.deps/drv_maildir.Tpo -c -o drv_maildir.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_maildir.c
mv -f .deps/drv_maildir.Tpo .deps/drv_maildir.Po
cc  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W -Wall 
-Wshadow -Wstrict-prototypes  -L/usr/local/lib/db4 -L/usr/lib -o mbsync main.o 
sync.o config.o  util.o drv_imap.o drv_maildir.o -ldb -lssl -lcrypto  
/usr/local/lib/db4/libdb.so.5.0: warning: strcpy() is almost always misused, 
please use strlcpy()
/usr/local/lib/db4/libdb.so.5.0: warning: rand() may return deterministic 
values, is that what you want?
/usr/local/lib/db4/libdb.so.5.0: warning: strcat() is almost always misused, 
please use strlcat()
drv_imap.o(.text+0x3cad): In function `imap_open_store':
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_imap.c:1400: warning: sprintf() 
is often misused, please use snprintf()
cc -DHAVE_CONFIG_H -I. -I/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src -I..    
-I/usr/include  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W 
-Wall -Wshadow -Wstrict-prototypes -MT mdconvert.o -MD -MP -MF 
.deps/mdconvert.Tpo -c -o mdconvert.o 
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/mdconvert.c
mv -f .deps/mdconvert.Tpo .deps/mdconvert.Po
cc  -O2 -pipe -ggdb -O0  -Wformat -I/usr/local/include/db4 -pipe -W -Wall 
-Wshadow -Wstrict-prototypes  -L/usr/local/lib/db4 -L/usr/lib -o mdconvert 
mdconvert.o -ldb 
/usr/local/lib/db4/libdb.so.5.0: warning: strcpy() is almost always misused, 
please use strlcpy()
/usr/local/lib/db4/libdb.so.5.0: warning: rand() may return deterministic 
values, is that what you want?
/usr/local/lib/db4/libdb.so.5.0: warning: strcat() is almost always misused, 
please use strlcat()
mdconvert.o(.text+0x8e4): In function `convert':
/usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/mdconvert.c:130: warning: sprintf() 
is often misused, please use snprintf()

######
# PATCH ( isync/patches/patch-nfsnprintf )
######
--- /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_maildir.c.orig
Wed Feb 20 08:28:19 2013
+++ /usr/ports/pobj/isync-1.0.6/isync-1.0.6/src/drv_maildir.c   Sat Feb
28 13:37:54 2015
@@ -936,7 +936,7 @@
        int ret, fd, bl;
        char buf[_POSIX_PATH_MAX], nbuf[_POSIX_PATH_MAX], fbuf[NUM_FLAGS
+ 3], base[128];

-       bl = nfsnprintf( base, sizeof(base), "%ld.%d_%d.%s", time( 0 ),
Pid, ++MaildirCount, Hostname );
+       bl = nfsnprintf( base, sizeof(base), "%lld.%d_%d.%s", (long
long)time( 0 ), Pid, ++MaildirCount, Hostname );
        if (uid) {
 #ifdef USE_DB
                if (ctx->db) {
@@ -1086,8 +1086,8 @@
        for (;;) {
                nfsnprintf( buf, sizeof(buf), "%s/%s/%s", gctx->path,
subdirs[gmsg->status & M_RECENT], msg->base );
                s = strstr( msg->base, ":2," );
-               nfsnprintf( nbuf, sizeof(nbuf),
"%s%s/%s/%ld.%d_%d.%s%s", gctx->conf->path, gctx->conf->trash,
-                           subdirs[gmsg->status & M_RECENT], time( 0 ),
Pid, ++MaildirCount, Hostname, s ? s : "" );
+               nfsnprintf( nbuf, sizeof(nbuf),
"%s%s/%s/%lld.%d_%d.%s%s", gctx->conf->path, gctx->conf->trash,
+                           subdirs[gmsg->status & M_RECENT],  (long
long)time( 0 ), Pid, ++MaildirCount, Hostname, s ? s : "" );
                if (!rename( buf, nbuf ))
                        break;
                if (!stat( buf, &st )) {
###### END ######

> 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

Reply via email to