|
| 1 | +From 60c822c3ddd52c1e872b7cd3d89ae3081e455ee3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: AllSpark <allspark@microsoft.com> |
| 3 | +Date: Wed, 11 Mar 2026 19:55:36 +0000 |
| 4 | +Subject: [PATCH] Check return code of UTF8_putc |
| 5 | + |
| 6 | +Signed-off-by: Norbert Pocs <norbertp@openssl.org> |
| 7 | + |
| 8 | +Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> |
| 9 | + |
| 10 | +Reviewed-by: Viktor Dukhovni <viktor@openssl.org> |
| 11 | + |
| 12 | +(Merged from https://github.com/openssl/openssl/pull/29376) |
| 13 | + |
| 14 | +Signed-off-by: rpm-build <rpm-build> |
| 15 | +Upstream-reference: AI Backport of https://github.com/openssl/openssl/commit/41be0f216404f14457bbf3b9cc488dba60b49296.patch |
| 16 | +--- |
| 17 | + CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_strex.c | 6 ++++-- |
| 18 | + .../Library/OpensslLib/openssl/crypto/pkcs12/p12_utl.c | 5 +++++ |
| 19 | + 2 files changed, 9 insertions(+), 2 deletions(-) |
| 20 | + |
| 21 | +diff --git a/CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_strex.c b/CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_strex.c |
| 22 | +index b31761a..f4c92fc 100644 |
| 23 | +--- a/CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_strex.c |
| 24 | ++++ b/CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_strex.c |
| 25 | +@@ -203,8 +203,10 @@ static int do_buf(unsigned char *buf, int buflen, |
| 26 | + orflags = CHARTYPE_LAST_ESC_2253; |
| 27 | + if (type & BUF_TYPE_CONVUTF8) { |
| 28 | + unsigned char utfbuf[6]; |
| 29 | +- int utflen; |
| 30 | +- utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c); |
| 31 | ++ int utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c); |
| 32 | ++ |
| 33 | ++ if (utflen < 0) |
| 34 | ++ return -1; /* error happened with UTF8 */ |
| 35 | + for (i = 0; i < utflen; i++) { |
| 36 | + /* |
| 37 | + * We don't need to worry about setting orflags correctly |
| 38 | +diff --git a/CryptoPkg/Library/OpensslLib/openssl/crypto/pkcs12/p12_utl.c b/CryptoPkg/Library/OpensslLib/openssl/crypto/pkcs12/p12_utl.c |
| 39 | +index 3afc8b2..dfd8829 100644 |
| 40 | +--- a/CryptoPkg/Library/OpensslLib/openssl/crypto/pkcs12/p12_utl.c |
| 41 | ++++ b/CryptoPkg/Library/OpensslLib/openssl/crypto/pkcs12/p12_utl.c |
| 42 | +@@ -212,6 +212,11 @@ char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen) |
| 43 | + /* re-run the loop emitting UTF-8 string */ |
| 44 | + for (asclen = 0, i = 0; i < unilen; ) { |
| 45 | + j = bmp_to_utf8(asctmp+asclen, uni+i, unilen-i); |
| 46 | ++ /* when UTF8_putc fails */ |
| 47 | ++ if (j < 0) { |
| 48 | ++ OPENSSL_free(asctmp); |
| 49 | ++ return NULL; |
| 50 | ++ } |
| 51 | + if (j == 4) i += 4; |
| 52 | + else i += 2; |
| 53 | + asclen += j; |
| 54 | +-- |
| 55 | +2.45.4 |
| 56 | + |
0 commit comments