mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
netutils: smtp: treat recv EOF as an error
recv() returns zero when the peer closes the TCP connection cleanly. The SMTP response path only treated negative returns as errors, so EOF could leave stale or empty response data to be checked as if a server reply had arrived. Return ERROR on zero-length receives at each SMTP response point and keep the SPDX copyright header within the project line length limit. Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
This commit is contained in:
parent
13f04f65b1
commit
fd525988f8
1 changed files with 9 additions and 8 deletions
|
|
@ -3,7 +3,8 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SPDX-FileCopyrightText: 2015, 2020 Gregory Nutt. All rights reserved.
|
||||
* SPDX-FileCopyrightText: 2007, 2009, 2011, Gregory Nutt. All rights reserved.
|
||||
* SPDX-FileCopyrightText: 2007, 2009, Gregory Nutt. All rights reserved.
|
||||
* SPDX-FileCopyrightText: 2011, Gregory Nutt. All rights reserved.
|
||||
* SPDX-FileCopyrightText: 2004, Adam Dunkels. All rights reserved.
|
||||
* SPDX-FileContributor: Gregory Nutt <gnutt@nuttx.org>
|
||||
* SPDX-FileContributor: Adam Dunkels <adam@dunkels.com>
|
||||
|
|
@ -116,7 +117,7 @@ static const char g_smtpto[] = "To: ";
|
|||
|
||||
static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
||||
{
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -133,7 +134,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -150,7 +151,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -167,7 +168,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -186,7 +187,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -202,7 +203,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -254,7 +255,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) < 0)
|
||||
if (recv(sockfd, psmtp->buffer, SMTP_INPUT_BUFFER_SIZE, 0) <= 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue