From 250a20575b7b5dfa41d2faa230b3682adece35f2 Mon Sep 17 00:00:00 2001 From: Franc Urbanc Date: Thu, 20 Aug 2026 09:47:38 +0200 Subject: [PATCH 1/2] Network: Fix character comparison for 8-bit values --- Components/Network/Source/net_smtp_client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Components/Network/Source/net_smtp_client.c b/Components/Network/Source/net_smtp_client.c index 5ba74f30..a2778889 100644 --- a/Components/Network/Source/net_smtp_client.c +++ b/Components/Network/Source/net_smtp_client.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------------ * MDK Middleware - Component ::Network - * Copyright (c) 2004-2024 Arm Limited (or its affiliates). All rights reserved. + * Copyright (c) 2004-2026 Arm Limited (or its affiliates). All rights reserved. *------------------------------------------------------------------------------ * Name: net_smtp_client.c * Purpose: Mail Transfer Client advanced blocking mode @@ -716,7 +716,7 @@ static uint32_t mime_encode_word (char *buf, const char *sp, uint32_t len) { /* Count escaped 7-bit characters */ n++; } - else if (ch > 127) { + else if ((uint8_t)ch > 127) { /* Count 8-bit characters */ j++; } @@ -755,7 +755,7 @@ static uint32_t mime_encode_word (char *buf, const char *sp, uint32_t len) { buf[n++] = '_'; continue; } - if ((sp[j] > 127) || (sp[j] == '_') || (sp[j] == '=')) { + if (((uint8_t)sp[j] > 127) || (sp[j] == '_') || (sp[j] == '=')) { /* Quoted-printable encoding "=XX" */ buf[n] = '='; buf[n+1] = hex_digit[sp[j] >> 4]; @@ -823,7 +823,7 @@ static uint32_t mime_encode_line_qp (char *buf) { for (n = i = 0; n < 76; i++) { /* 8-bit ascii or '=' character, store encoded */ - if ((sp[i] > 127) || (sp[i] == '=')) { + if (((uint8_t)sp[i] > 127) || (sp[i] == '=')) { buf[n] = '='; buf[n+1] = hex_digit[sp[i] >> 4]; buf[n+2] = hex_digit[sp[i] & 0x0F]; @@ -864,7 +864,7 @@ static bool check_8bit (const NET_SMTP_MAIL *mail) { if (mail->Message && mail->Encoding && mail->Encoding[0]) { /* Scan the message */ for (i = 0; mail->Message[i]; i++) { - if (mail->Message[i] > 127) { + if ((uint8_t)mail->Message[i] > 127) { return (true); } } From 89c9ec3a5036066ce2c098bc1858a79d619cac48 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 10:49:51 +0000 Subject: [PATCH 2/2] Fix signed-char nibble indexing in SMTP MIME encoding Co-authored-by: RobertRostohar <8438377+RobertRostohar@users.noreply.github.com> --- Components/Network/Source/net_smtp_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Components/Network/Source/net_smtp_client.c b/Components/Network/Source/net_smtp_client.c index a2778889..3102911e 100644 --- a/Components/Network/Source/net_smtp_client.c +++ b/Components/Network/Source/net_smtp_client.c @@ -758,8 +758,8 @@ static uint32_t mime_encode_word (char *buf, const char *sp, uint32_t len) { if (((uint8_t)sp[j] > 127) || (sp[j] == '_') || (sp[j] == '=')) { /* Quoted-printable encoding "=XX" */ buf[n] = '='; - buf[n+1] = hex_digit[sp[j] >> 4]; - buf[n+2] = hex_digit[sp[j] & 0x0F]; + buf[n+1] = hex_digit[(uint8_t)sp[j] >> 4]; + buf[n+2] = hex_digit[(uint8_t)sp[j] & 0x0F]; n += 3; continue; } @@ -825,8 +825,8 @@ static uint32_t mime_encode_line_qp (char *buf) { /* 8-bit ascii or '=' character, store encoded */ if (((uint8_t)sp[i] > 127) || (sp[i] == '=')) { buf[n] = '='; - buf[n+1] = hex_digit[sp[i] >> 4]; - buf[n+2] = hex_digit[sp[i] & 0x0F]; + buf[n+1] = hex_digit[(uint8_t)sp[i] >> 4]; + buf[n+2] = hex_digit[(uint8_t)sp[i] & 0x0F]; n += 3; continue; }