summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus
diff options
context:
space:
mode:
authoryuhzheng <yuhzheng@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2019-12-04 07:52:49 +0000
committeryuhzheng <yuhzheng@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2019-12-04 07:52:49 +0000
commit46c99194f6dc6dbe9abcfb6cd5643fd2a813e90e (patch)
tree778801f8a1d35d66bc11b2ef3c2aed8b0f675773 /FreeRTOS-Plus
parentef20723f20063f721132f3830fb7b920aff4cac1 (diff)
downloadfreertos-46c99194f6dc6dbe9abcfb6cd5643fd2a813e90e.tar.gz
Check socket binding result before doing anything with socket. (This is to address ARG findings.) Breaking the single return rule here, due to precedent violation at line 1039 and 1144.
prvTransferConnect() now returns: - pdTRUE: everything's good. pdTRUE = 1. - -pdFREERTOS_ERRNO_ENOMEM: FreeRTOS_socket() failed. -pdFREERTOS_ERRNO_ENOMEM = -12. - -pdFREERTOS_ERRNO_EINVAL || -pdFREERTOS_ERRNO_ECANCELED: FreeRTOS_bind() failed. Negative values. Thus, at line 569 and line 617, needs to check != pdTRUE instead of == pdFALSE. This commit is done on behalf of Alfred. git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2759 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS-Plus')
-rw-r--r--FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c b/FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c
index a2a6ba155..2d0c9197e 100644
--- a/FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c
+++ b/FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c
@@ -566,7 +566,7 @@ BaseType_t xResult = 0;
case ECMD_PASV: /* Enter passive mode. */
/* Connect passive: Server will listen() and wait for a connection.
Start up a new data connection with 'xDoListen' set to true. */
- if( prvTransferConnect( pxClient, pdTRUE ) == pdFALSE )
+ if( prvTransferConnect( pxClient, pdTRUE ) != pdTRUE )
{
pcMyReply = REPL_502;
}
@@ -614,7 +614,7 @@ BaseType_t xResult = 0;
{
pcMyReply = REPL_501;
}
- else if( prvTransferConnect( pxClient, pdFALSE ) == pdFALSE )
+ else if( prvTransferConnect( pxClient, pdFALSE ) != pdTRUE )
{
/* Call prvTransferConnect() with 'xDoListen' = false for an
active connect(). */
@@ -850,7 +850,13 @@ BaseType_t xResult;
xAddress.sin_addr = FreeRTOS_GetIPAddress( ); /* Single NIC, currently not used */
xAddress.sin_port = FreeRTOS_htons( 0 ); /* Bind to any available port number */
- FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
+ BaseType_t xBindResult;
+ xBindResult = FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
+ if ( xBindResult != 0 )
+ {
+ FreeRTOS_printf( ( "FreeRTOS_bind() failed\n" ) );
+ return xBindResult;
+ }
#if( ipconfigFTP_TX_BUFSIZE > 0 )
{