From: Joshua Rogers Date: Sat, 11 Oct 2025 12:24:58 +0000 (+0800) Subject: asn_mime: Harden strip_eol() X-Git-Tag: 4.0-PRE-CLANG-FORMAT-WEBKIT~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f9db2608d199731f5ae7e689e895e6fe38bf9d9;p=thirdparty%2Fopenssl.git asn_mime: Harden strip_eol() Signed-off-by: Joshua Rogers Reviewed-by: Saša Nedvědický Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/28881) --- diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index c2aceffc1cf..c9bdfd98c84 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -1048,6 +1048,11 @@ static int strip_eol(char *linebuf, int *plen, int flags) char *p, c; int is_eol = 0; + if (len <= 0) { + *plen = 0; + return 0; + } + #ifndef OPENSSL_NO_CMS if ((flags & CMS_BINARY) != 0) { if (len <= 0 || linebuf[len - 1] != '\n')