]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn_mime: Harden strip_eol()
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 12:24:58 +0000 (20:24 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 18 Nov 2025 16:53:40 +0000 (17:53 +0100)
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28881)

crypto/asn1/asn_mime.c

index c2aceffc1cf7b05ed02ed0b44778af3aadcf7fb7..c9bdfd98c848f24f56cfee81c3ac4fde31af676e 100644 (file)
@@ -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')