File openssl-CVE-2025-69419.patch of Package openssl-3.42400

From 41be0f216404f14457bbf3b9cc488dba60b49296 Mon Sep 17 00:00:00 2001
From: Norbert Pocs <norbertp@openssl.org>
Date: Thu, 11 Dec 2025 12:49:00 +0100
Subject: [PATCH] Check return code of UTF8_putc

Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29376)
---
 crypto/asn1/a_strex.c   | 6 ++++--
 crypto/pkcs12/p12_utl.c | 5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

Index: openssl-3.0.8/crypto/asn1/a_strex.c
===================================================================
--- openssl-3.0.8.orig/crypto/asn1/a_strex.c
+++ openssl-3.0.8/crypto/asn1/a_strex.c
@@ -203,8 +203,10 @@ static int do_buf(unsigned char *buf, in
             orflags = CHARTYPE_LAST_ESC_2253;
         if (type & BUF_TYPE_CONVUTF8) {
             unsigned char utfbuf[6];
-            int utflen;
-            utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c);
+            int utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c);
+
+            if (utflen < 0)
+                return -1; /* error happened with UTF8 */
             for (i = 0; i < utflen; i++) {
                 /*
                  * We don't need to worry about setting orflags correctly
Index: openssl-3.0.8/crypto/pkcs12/p12_utl.c
===================================================================
--- openssl-3.0.8.orig/crypto/pkcs12/p12_utl.c
+++ openssl-3.0.8/crypto/pkcs12/p12_utl.c
@@ -212,6 +212,11 @@ char *OPENSSL_uni2utf8(const unsigned ch
     /* re-run the loop emitting UTF-8 string */
     for (asclen = 0, i = 0; i < unilen; ) {
         j = bmp_to_utf8(asctmp+asclen, uni+i, unilen-i);
+        /* when UTF8_putc fails */
+        if (j < 0) {
+            OPENSSL_free(asctmp);
+            return NULL;
+        }
         if (j == 4) i += 4;
         else        i += 2;
         asclen += j;
openSUSE Build Service is sponsored by