Package: 1137386
Followup-For: Bug #1137386
X-Debbugs-Cc: [email protected]
Control: tags -1 patch ftbfs

The attached patch fixes the build issue with OpenSSL 4.0.


-- System Information:
Debian Release: trixie/sid
  APT prefers noble-updates
  APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), 
(100, 'noble-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.8.0-117-generic (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Description: Fix build with OpenSSL 4.0
 Use ASN1_STRING_get0_data() accessor instead of directly accessing
 the ->data field of ASN1_IA5STRING, which is now an opaque type.
Author: Ravi Kant Sharma <[email protected]>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2154824
Bug-Debian: https://bugs.debian.org/1137386
Forwarded: no
Last-Update: 2026-06-12

--- a/imap/src/osdep/nt/ssl_libressl.c
+++ b/imap/src/osdep/nt/ssl_libressl.c
@@ -529,11 +529,11 @@
        /* older versions of OpenSSL use "ia5" instead of dNSName */
        for (i = 0; ret && (i < n); i++)
         if ((name = sk_GENERAL_NAME_value (ext,i)) &&
-           (name->type = GEN_DNS) && (s = name->d.ia5->data) &&
+           (name->type = GEN_DNS) && (s = (char *) 
ASN1_STRING_get0_data(name->d.ia5)) &&
            ssl_compare_hostnames (host,s)) ret = NIL;
   }
 #endif /* OPENSSL_1_1_0 */
-                               /* Method 2, use Cname */
+                       /* Method 2, use Cname */
   if(m == 0 || ret != NIL){
      cname = X509_get_subject_name(cert);
      for(j = 0, ret = NIL; j < X509_NAME_entry_count(cname) && ret == NIL; 
j++){
@@ -552,7 +552,7 @@
                   /* older versions of OpenSSL use "ia5" instead of dNSName */
              for (i = 0; ret && (i < n); i++)
                  if ((name = sk_GENERAL_NAME_value (ext,i)) &&
-                    (name->type = GEN_DNS) && (s = name->d.ia5->data) &&
+                    (name->type = GEN_DNS) && (s = (char *) 
ASN1_STRING_get0_data(name->d.ia5)) &&
                     ssl_compare_hostnames (host,s)) ret = NIL;
         }
      }
--- a/imap/src/osdep/unix/ssl_unix.c
+++ b/imap/src/osdep/unix/ssl_unix.c
@@ -546,7 +546,7 @@
        /* older versions of OpenSSL use "ia5" instead of dNSName */
        for (i = 0; ret && (i < n); i++)
         if ((name = sk_GENERAL_NAME_value (ext,i)) &&
-           (name->type = GEN_DNS) && (s = name->d.ia5->data) &&
+           (name->type = GEN_DNS) && (s = (char *) 
ASN1_STRING_get0_data(name->d.ia5)) &&
            ssl_compare_hostnames (host,s)) ret = NIL;
      if(ext) GENERAL_NAMES_free(ext);
   }
@@ -571,7 +571,7 @@
                   /* older versions of OpenSSL use "ia5" instead of dNSName */
              for (i = 0; ret && (i < n); i++)
                  if ((name = sk_GENERAL_NAME_value (ext,i)) &&
-                    (name->type = GEN_DNS) && (s = name->d.ia5->data) &&
+                    (name->type = GEN_DNS) && (s = (char *) 
ASN1_STRING_get0_data(name->d.ia5)) &&
                     ssl_compare_hostnames (host,s)) ret = NIL;
          if(ext) GENERAL_NAMES_free(ext);
         }
--- a/alpine/smime.c
+++ b/alpine/smime.c
@@ -395,9 +395,9 @@
        int i;
 
        bs = X509_get_serialNumber(cert);
-       if (bs->length <= (int)sizeof(long)){
+       if (ASN1_STRING_length(bs) <= (int)sizeof(long)){
           l = ASN1_INTEGER_get(bs);
-           if (bs->type == V_ASN1_NEG_INTEGER){
+           if (ASN1_STRING_type(bs) == V_ASN1_NEG_INTEGER){
              l = -l;
              neg="-";
           }
@@ -405,10 +405,10 @@
               neg="";
           snprintf(buf, sizeof(buf), " %s%lu (%s0x%lx)", neg, l, neg, l);
        } else {
-           snprintf(buf, sizeof(buf), "%s", bs->type == V_ASN1_NEG_INTEGER ? 
"(Negative)" : "");
-           for (i = 0; i < bs->length; i++)
-                snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), 
"%02x%s", bs->data[i],
-                       i+1 == bs->length ? "" : ":");
+           snprintf(buf, sizeof(buf), "%s", ASN1_STRING_type(bs) == 
V_ASN1_NEG_INTEGER ? "(Negative)" : "");
+           for (i = 0; i < ASN1_STRING_length(bs); i++)
+                snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), 
"%02x%s", ASN1_STRING_get0_data(bs)[i],
+                       i+1 == ASN1_STRING_length(bs) ? "" : ":");
        }
     }
     gf_puts(buf, spc);

Reply via email to