[balsa] smtp: fix possible uninitialised memory access



commit cbdafb7c5756737cb2e439b727f406ed3f68f169
Author: Albrecht Dreß <albrecht dress netcologne de>
Date:   Fri Jul 30 19:53:28 2021 +0200

    smtp: fix possible uninitialised memory access
    
    do not access uninitialised memory iff the SMTP server sends a too short
    reply
    
    Signed-off-by: Albrecht Dreß <albrecht dress netcologne de>

 libnetclient/net-client-smtp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/libnetclient/net-client-smtp.c b/libnetclient/net-client-smtp.c
index 3d20fa17a..7171a2fb2 100644
--- a/libnetclient/net-client-smtp.c
+++ b/libnetclient/net-client-smtp.c
@@ -673,7 +673,7 @@ net_client_smtp_read_reply(NetClientSmtp *client, gint expect_code, gchar **last
                        } else {
                                /* nothing to do (see MISRA C:2012, Rule 15.7) */
                        }
-                       if (reply[3] == ' ') {
+                       if ((strlen(reply) > 3UL) && (reply[3] == ' ')) {
                                done = TRUE;
                                if (last_reply != NULL) {
                                        *last_reply = g_strdup(&reply[4]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]