Kaynağa Gözat

Fix bug #55034: apps/smtp.c fails to compile with strict C compatibility because of strnlen

by replacing strnlen with strlen. It's a user-supplied string, so we can assume it is correctly \0 terminated (as done several times elsewhere in the code)

(cherry picked from commit aa83bdf490a8b4573823619bfe48e2e75d9dbd49)
Dirk Ziegelmeier 7 yıl önce
ebeveyn
işleme
66706f469d
1 değiştirilmiş dosya ile 3 ekleme ve 4 silme
  1. 3 4
      src/apps/smtp/smtp.c

+ 3 - 4
src/apps/smtp/smtp.c

@@ -65,7 +65,7 @@
 #include "lwip/altcp_tcp.h"
 #include "lwip/altcp_tls.h"
 
-#include <string.h> /* strnlen, memcpy */
+#include <string.h> /* strlen, memcpy */
 #include <stdlib.h>
 
 /** TCP poll interval. Unit is 0.5 sec. */
@@ -353,9 +353,8 @@ smtp_set_server_addr(const char* server)
   LWIP_ASSERT_CORE_LOCKED();
 
   if (server != NULL) {
-    /* strnlen: returns length WITHOUT terminating 0 byte OR
-     * SMTP_MAX_SERVERNAME_LEN+1 when string is too long */
-    len = strnlen(server, SMTP_MAX_SERVERNAME_LEN+1);
+    /* strlen: returns length WITHOUT terminating 0 byte */
+    len = strlen(server);
   }
   if (len > SMTP_MAX_SERVERNAME_LEN) {
     return ERR_MEM;