smtp.c: Fix detecting overlength server names

Thanks to Axel Lin
This commit is contained in:
Dirk Ziegelmeier 2017-06-14 22:06:37 +02:00
parent 67d1970059
commit 5a27e97baf

View File

@ -346,7 +346,9 @@ smtp_set_server_addr(const char* server)
{
size_t len = 0;
if (server != NULL) {
len = strnlen(server, SMTP_MAX_SERVERNAME_LEN); /* strnlen: length WITHOUT terminating 0 byte */
/* 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);
}
if (len > SMTP_MAX_SERVERNAME_LEN) {
return ERR_MEM;