cyrusimap / cyrus-sasl

Other
134 stars 151 forks source link

auth_pam.c does not compile: `* semicol = NULL` — error: assignment to ‘char’ from ‘void *’ makes integer from pointer without a cast #838

Closed dilyanpalauzov closed 4 months ago

dilyanpalauzov commented 5 months ago

With gcc 14 compilation fails:

make[2]: Entering directory '/git/cyrus/cyrus-sasl/saslauthd'
depbase=`echo auth_pam.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -DSASLAUTHD_CONF_FILE_DEFAULT=\"/usr/local/etc/saslauthd.conf\" -I. -I. -I.. -I. -I..  -I../include -I../include -I../common -I../common -I/usr/local/include -I -I -I -I  -Wall -W -g -O2 -pthread -MT auth_pam.o -MD -MP -MF $depbase.Tpo -c -o auth_pam.o auth_pam.c &&\
mv -f $depbase.Tpo $depbase.Po
auth_pam.c: In function ‘auth_pam’:
auth_pam.c:209:32: error: assignment to ‘char’ from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  209 |         if (semicol) * semicol = NULL; /* truncate remote_host at the ';' port separator */
      |                                ^
make[2]: *** [Makefile:559: auth_pam.o] Error 1
make[2]: Leaving directory '/git/cyrus/cyrus-sasl/saslauthd'
dilyanpalauzov commented 5 months ago
     char * remote_host = strdup(remote);
     if (remote_host) {
        char * semicol = strchr(remote_host, ';');
-       if (semicol) * semicol = NULL; /* truncate remote_host at the ';' port separator */
+       if (semicol) *semicol = '\0'; /* truncate remote_host at the ';' port separator */
        pam_set_item(pamh, PAM_RHOST, remote_host);
        free (remote_host);
     }
dschepler commented 4 months ago

And a couple more gcc-14 related compilation errors:

make[3]: Entering directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/lib'
depbase=`echo saslutil.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../lib -I..  -DLIBSASL_EXPORTS=1 -I../../../include -I../../../plugins -I../include -I../../../sasldb -I../../../common -DCONFIGDIR='"/usr/lib64/sasl2:/etc/sasl2"' -DPLUGINDIR='"/usr/lib64/sasl2"' -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1  -Wall -W -g -O2 -MT saslutil.lo -MD -MP -MF $depbase.Tpo -c -o saslutil.lo ../../../lib/saslutil.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../lib -I.. -DLIBSASL_EXPORTS=1 -I../../../include -I../../../plugins -I../include -I../../../sasldb -I../../../common -DCONFIGDIR=\"/usr/lib64/sasl2:/etc/sasl2\" -DPLUGINDIR=\"/usr/lib64/sasl2\" -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1 -Wall -W -g -O2 -MT saslutil.lo -MD -MP -MF .deps/saslutil.Tpo -c ../../../lib/saslutil.c  -fPIC -DPIC -o .libs/saslutil.o
../../../lib/saslutil.c: In function 'sasl_mkchal':
../../../lib/saslutil.c:280:3: error: implicit declaration of function 'time' [-Wimplicit-function-declaration]
  280 |   time(&now);
      |   ^~~~
../../../lib/saslutil.c:66:1: note: 'time' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
   65 | #include "saslint.h"
  +++ |+#include <time.h>
   66 | #include <saslutil.h>
../../../lib/saslutil.c: In function 'getranddata':
../../../lib/saslutil.c:364:41: error: implicit declaration of function 'clock' [-Wimplicit-function-declaration]
  364 |             ret[1] ^= (unsigned short) (clock() & 0xFFFF);
      |                                         ^~~~~
../../../lib/saslutil.c:364:41: note: 'clock' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
../../../lib/saslutil.c: In function 'get_fqhostname':
../../../lib/saslutil.c:563:42: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  563 |         || strlen (result->ai_canonname) > namelen -1) {
      |                                          ^
make[3]: *** [Makefile:643: saslutil.lo] Error 1
make[3]: Target 'all-am' not remade because of errors.
make[3]: Leaving directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/lib'
make[2]: *** [Makefile:507: all] Error 2
make[2]: Leaving directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/lib'
Making all in plugins
make[2]: Entering directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/plugins'
depbase=`echo cram.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../plugins -I..  -DLIBSASL_EXPORTS=1 -I../../../include -I../../../lib -I../../../sasldb -I../../../common -I../include -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1  -Wall -W -g -O2 -MT cram.lo -MD -MP -MF $depbase.Tpo -c -o cram.lo ../../../plugins/cram.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../plugins -I.. -DLIBSASL_EXPORTS=1 -I../../../include -I../../../lib -I../../../sasldb -I../../../common -I../include -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1 -Wall -W -g -O2 -MT cram.lo -MD -MP -MF .deps/cram.Tpo -c ../../../plugins/cram.c  -fPIC -DPIC -o .libs/cram.o
../../../plugins/cram.c: In function 'gettime':
../../../plugins/cram.c:132:7: error: implicit declaration of function 'time' [-Wimplicit-function-declaration]
  132 |     t=time(NULL);
      |       ^~~~
../../../plugins/cram.c:61:1: note: 'time' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
   60 | #include "plugin_common.h"
  +++ |+#include <time.h>
   61 | 
make[2]: *** [Makefile:762: cram.lo] Error 1
make[2]: Target 'all' not remade because of errors.
make[2]: Leaving directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/plugins'
hyc commented 4 months ago

Implicit function declarations are legal C syntax and not errors. It is wrong for the compiler to treat them as such.

mistotebe commented 4 months ago

It became invalid in C99 (and even in C89 the assumed signature was int(void) which is clearly incompatible with time()'s signature)

hyc commented 4 months ago

And a couple more gcc-14 related compilation errors:


make[3]: Entering directory '/home/unfrobbed-dev/pkgs/cyrus-sasl/cyrus-sasl-2.1.28/debian/obj-amd64/lib'
depbase=`echo saslutil.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../lib -I..  -DLIBSASL_EXPORTS=1 -I../../../include -I../../../plugins -I../include -I../../../sasldb -I../../../common -DCONFIGDIR='"/usr/lib64/sasl2:/etc/sasl2"' -DPLUGINDIR='"/usr/lib64/sasl2"' -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1  -Wall -W -g -O2 -MT saslutil.lo -MD -MP -MF $depbase.Tpo -c -o saslutil.lo ../../../lib/saslutil.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../lib -I.. -DLIBSASL_EXPORTS=1 -I../../../include -I../../../plugins -I../include -I../../../sasldb -I../../../common -DCONFIGDIR=\"/usr/lib64/sasl2:/etc/sasl2\" -DPLUGINDIR=\"/usr/lib64/sasl2\" -DOBSOLETE_CRAM_ATTR=1 -DOBSOLETE_DIGEST_ATTR=1 -Wall -W -g -O2 -MT saslutil.lo -MD -MP -MF .deps/saslutil.Tpo -c ../../../lib/saslutil.c  -fPIC -DPIC -o .libs/saslutil.o
../../../lib/saslutil.c: In function 'sasl_mkchal':
../../../lib/saslutil.c:280:3: error: implicit declaration of function 'time' [-Wimplicit-function-declaration]
  280 |   time(&now);
      |   ^~~~
../../../lib/saslutil.c:66:1: note: 'time' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'

Note that saslutil.c already has a #include <time.h> if autoconf detected it. The fact that it wasn't defined in your build means there was something else wrong with your build environment, and there's nothing for us to change in saslutil.c itself.

https://github.com/cyrusimap/cyrus-sasl/blob/master/lib/saslutil.c#L63

Also, this is unrelated to auth_pam.c so if there is actually any issue, it belongs in a separate ticket.