Re: [PATCH gnupg] Fix gcc -Wunterminated-string-initialization warnings.
Jacob Bachmeyer via Gnupg-devel <[email protected]>
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 4/29/25 23:01, Collin Funk via Gnupg-devel wrote: > * common/ksba-io-support.c (ATTR_NONSTRING): New macro. > (bintoasc): Mark with ATTR_NONSTRING. > (has_only_base64): Use memchr since calling strchr on a non-NUL > terminated string is undefined behavior. > * dirmngr/dns.c (DNS_NONSTRING): New macro. > (dns_aaaa_arpa, dns_sshfp_print): Mark a variable with DNS_NONSTRING. The patch as written breaks compatibility with GCC < GCC8 and with other compilers because it neglects to define the new macros with empty expansions on older or non-GCC compilers. > [...] > diff --git a/common/ksba-io-support.c b/common/ksba-io-support.c > index 352485ffa..10419ab20 100644 > --- a/common/ksba-io-support.c > +++ b/common/ksba-io-support.c > @@ -51,6 +51,9 @@ > #define LF "\n" > #endif > > +#if __GNUC__ >= 8 > +# define ATTR_NONSTRING __attribute__ ((__nonstring__)) > +#endif > > /* Data used by the reader callbacks. */ > struct reader_cb_parm_s > [...] > diff --git a/dirmngr/dns.c b/dirmngr/dns.c > index 5c7bb08d8..bfab59f13 100644 > --- a/dirmngr/dns.c > +++ b/dirmngr/dns.c > @@ -131,6 +131,9 @@ typedef int socket_fd_t; > #if __GNUC__ > #define DNS_NOTUSED __attribute__((unused)) > #define DNS_NORETURN __attribute__((__noreturn__)) > +#if __GNUC__ >= 8 > +#define DNS_NONSTRING __attribute__((__nonstring__)) > +#endif > #else > #define DNS_NOTUSED > #define DNS_NORETURN > [...] -- Jacob _______________________________________________ Gnupg-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gnupg-devel