Bug 972

Summary: 1.9.6p1 uses C99 features without configuring for them
Product: Sudo Reporter: James Brown <jbrown>
Component: ConfigureAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal CC: mehmetgelisin
Priority: low    
Version: 1.9.6   
Hardware: PC   
OS: All   

Description James Brown 2021-04-05 17:57:20 MDT
sudo 1.9.6p1 (possibly also 1.9.6, but not 1.9.5p2) uses C99 features and fails to compile when built with a toolchain that defaults to C89/ANSI C.

./sendlog.c: In function 'main':
./sendlog.c:1835: error: 'for' loop initial declarations are only allowed in C99 mode
./sendlog.c:1835: note: use option -std=c99 or -std=gnu99 to compile your code

Building with CFLAGS="-std=c99" fixes this.

I believe configure.ac should include a call to AC_PROG_CC_C99
Comment 1 Todd C. Miller 2021-04-05 19:51:27 MDT
The configure script checks for options needed for C11 and if C11 is not supported, checks for C99 options.  You should see output like this from configure:

checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... unsupported
checking for gcc option to enable C99 features... -std=gnu99

Can you check your configure output to see what it says for
the C11 and C99 checks?  It's possible this is a bug in autoconf 2.71.
Comment 2 James Brown 2021-04-06 12:22:18 MDT
This definitely does appear to be an autoconf issue of some kind.

The configure script in the tarball checks for C99, but a new configure script generated after autoreconf doesn't. There are some warnings on autoreconf but no fatal errors, so I'm kind of at a loss where the issue is. This is with autoconf 2.69, for what it's worth; maybe some stanza you use requires a newer autoconf?

There's actually no reason for me to be running autoreconf, since I'm not patching anything in the build system, so I won't worry about it for now.
Comment 3 Todd C. Miller 2021-04-06 14:40:03 MDT
I've bumped the autoconf minimum version in configure.ac to 2.70 which should avoid this kind of problem in the future.  Some of the macros deprecated in 2.70 are required by older versions.  For example, AC_PROG_CC now does the work of AC_PROG_CC_STDC.
Comment 4 Todd C. Miller 2021-05-12 07:36:02 MDT
Fixed in sudo 1.9.7