]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix -Wdiscarded-qualifiers warnings shown when glibc-2.43 is used
authorCollin Funk <collin.funk1@gmail.com>
Sat, 28 Mar 2026 07:41:01 +0000 (00:41 -0700)
committerEugene Syromiatnikov <esyr@openssl.org>
Tue, 31 Mar 2026 02:37:59 +0000 (04:37 +0200)
When building with glibc-2.43 there is the following warning:

    crypto/x509/x509_vpm.c: In function 'validate_email_name':
    crypto/x509/x509_vpm.c:317:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      317 |     if ((at = memchr(name, '@', len)) == NULL)
          |             ^

This is due to a change described in the NEWS file of glibc-2.43:

    * For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
      strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
      pointers into their input arrays now have definitions as macros that
      return a pointer to a const-qualified type when the input argument is
      a pointer to a const-qualified type.

Systems using this recent glibc version will likely also be using GCC 15
or later which default to `-std=gnu23`, meaning that this warning will
show up without modifying `CFLAGS`.

We can make these pointers const since we never write to them.

Complements: f584ae959cbc "Let's support multiple names for certificate verification"

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Mar 31 02:38:14 2026
(Merged from https://github.com/openssl/openssl/pull/30613)

crypto/x509/x509_vpm.c

index 410e690e83eae69e961904abed061b1025d6125b..aa606f632022dc0ef2b2756d56c7ac3ce79b0f2a 100644 (file)
@@ -304,7 +304,7 @@ static int validate_local_part(const char *name, size_t len,
 static int validate_email_name(const char *name, size_t len, int rfc822)
 {
     size_t dns_len, local_len;
-    char *at, *next, *dnsname;
+    const char *at, *next, *dnsname;
     ossl_charset_t local_charset;
 
     /*