Re: [PATCH gnupg] Fix gcc -Wunterminated-string-initialization warnings.
Werner Koch via Gnupg-devel <[email protected]>
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi! On Tue, 29 Apr 2025 21:01, Collin Funk said: > (has_only_base64): Use memchr since calling strchr on a non-NUL > terminated string is undefined behavior. Very good catch. I was my fault 22 years ago: > -static char bintoasc[64] = > +static char bintoasc[64] ATTR_NONSTRING = > "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > "abcdefghijklmnopqrstuvwxyz" > "0123456789+/"; That is actually similar code as in g10/armor.c; which however uses bintoasc[] and thus let the compiler determine the array size. I can only speculate that I used the 64 byte array because the inverse asctobin array has a fixed size on purpose. Thanks for the patch. I am going to apply this to all branches. Regarding the nonstring attribute we need to wait that we can make libgpg-error 1.55 a requirement. That version provides the GPGRT_ATTR_NONSTRING. For master we might soon make this a dependency but not for the other branches. Shalom-Salam, Werner -- The pioneers of a warless world are the youth that refuse military service. - A. Einstein _______________________________________________ Gnupg-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gnupg-devel
openpgp-digital-signature.asc
(application/pgp-signature, 247 B)
-----BEGIN PGP SIGNATURE----- iIMEARYKACsWIQSHd0YfKgdOvEgNNZQZzByeCFsQegUCaBHe4w0cd2tAZ251cGcu b3JnAAoJEBnMHJ4IWxB6e7QBAMv/48fair7xIE4iol4r7maxwY8/2MGo5Q6ffoPR UlyPAP4kxIxXf2+XS9OmIJTlYDjpy4WHLDNy6T5GYLENnUplBA== =4zWn -----END PGP SIGNATURE-----