sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.16k stars 208 forks source link

Do variable length arrays the C99 way #266

Closed RSilicon closed 1 year ago

RSilicon commented 1 year ago

Variable length arrays are supported by C99, but having it denoted as "1" confused the compiler and is not defined.

Note that because we don't get the inferred NULL terminator, we have to increase the malloc size by one.

RSilicon commented 1 year ago

@millert Thoughts on this?

millert commented 1 year ago

My concern is that there are probably still people building sudo with a pre-C99 compiler which may not support C99 flexible array members.

RSilicon commented 1 year ago

My concern is that there are probably still people building sudo with a pre-C99 compiler which may not support C99 flexible array members.

I thought C99 was a prerequisite for building this program...

millert commented 1 year ago

Sudo can still be built with a C89 compiler, though some of the the debug functionality will be omitted if the preprocessor is missing varargs support (either gcc or C99 style). I reached out to someone I know who builds sudo for older platforms and it doesn't look like this change will cause problems.