From 3073affaaf1bc5bedd946e7c7969207e2a206b9a Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 14 Jun 2017 14:11:27 +0200 Subject: [PATCH] Axel Lin correctly pointed out that there is no buffer overflow because smtp_server[SMTP_MAX_SERVERNAME_LEN + 1] - there is always room for terminating 0 byte --- src/apps/smtp/smtp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/smtp/smtp.c b/src/apps/smtp/smtp.c index 3c30811d..2e58933e 100644 --- a/src/apps/smtp/smtp.c +++ b/src/apps/smtp/smtp.c @@ -348,13 +348,13 @@ smtp_set_server_addr(const char* server) if (server != NULL) { len = strnlen(server, SMTP_MAX_SERVERNAME_LEN); /* strnlen: length WITHOUT terminating 0 byte */ } - if (len >= SMTP_MAX_SERVERNAME_LEN) { - return ERR_MEM; /* too long or no room for terminating 0 byte */ + if (len > SMTP_MAX_SERVERNAME_LEN) { + return ERR_MEM; } if (len != 0) { MEMCPY(smtp_server, server, len); } - smtp_server[len] = 0; + smtp_server[len] = 0; /* always OK because of smtp_server[SMTP_MAX_SERVERNAME_LEN + 1] */ return ERR_OK; }