From a3fcf41e1a846f6b3fa66ed839a2dd9db4841c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Trojnara?= Date: Thu, 19 Jun 2025 11:32:54 +0200 Subject: [PATCH] Check memory allocation --- script.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script.c b/script.c index 87326d8..8a957e6 100644 --- a/script.c +++ b/script.c @@ -353,6 +353,8 @@ static PKCS7 *script_pkcs7_extract(FILE_FORMAT_CTX *ctx) if (ctx->script_ctx->utf == 8) { base64_len = signature_len; base64_data = OPENSSL_malloc(base64_len); + if (!base64_data) + return NULL; /* memory allocation failed */ memcpy(base64_data, signature_data, base64_len); } else { base64_len = utf16_to_utf8((const void *)signature_data, @@ -691,6 +693,8 @@ static int write_commented(FILE_FORMAT_CTX *ctx, BIO *outdata, const char *data, * - closing tag * - trailing NUL ("\0") */ line = OPENSSL_malloc(2 + open_tag_len + length + close_tag_len + 1); + if (!line) + return 0; /* memory allocation failed */ strcpy(line, "\r\n"); strcat(line, open_tag); memcpy(line + 2 + open_tag_len, data, length);