]> git.sur5r.net Git - freertos/commitdiff
Check socket binding result before doing anything with socket. (This is to address...
authoryuhzheng <yuhzheng@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 4 Dec 2019 07:52:49 +0000 (07:52 +0000)
committeryuhzheng <yuhzheng@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 4 Dec 2019 07:52:49 +0000 (07:52 +0000)
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: https://svn.code.sf.net/p/freertos/code/trunk@2759 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/FTP/FreeRTOS_FTP_server.c

index a2a6ba155f36ad36cb886816dbd9e11a864ac04f..2d0c9197ea97919740cd7bfecdf1bcf56633b214 100644 (file)
@@ -566,7 +566,7 @@ BaseType_t xResult = 0;
                case ECMD_PASV: /* Enter passive mode. */\r
                        /* Connect passive: Server will listen() and wait for a connection.\r
                        Start up a new data connection with 'xDoListen' set to true. */\r
-                       if( prvTransferConnect( pxClient, pdTRUE ) == pdFALSE )\r
+                       if( prvTransferConnect( pxClient, pdTRUE ) != pdTRUE )\r
                        {\r
                                pcMyReply = REPL_502;\r
                        }\r
@@ -614,7 +614,7 @@ BaseType_t xResult = 0;
                                {\r
                                        pcMyReply = REPL_501;\r
                                }\r
-                               else if( prvTransferConnect( pxClient, pdFALSE ) == pdFALSE )\r
+                               else if( prvTransferConnect( pxClient, pdFALSE ) != pdTRUE )\r
                                {\r
                                        /* Call prvTransferConnect() with 'xDoListen' = false for an\r
                                        active connect(). */\r
@@ -850,7 +850,13 @@ BaseType_t xResult;
                xAddress.sin_addr = FreeRTOS_GetIPAddress( );   /* Single NIC, currently not used */\r
                xAddress.sin_port = FreeRTOS_htons( 0 );                /* Bind to any available port number */\r
 \r
-               FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );\r
+               BaseType_t xBindResult;\r
+               xBindResult = FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );\r
+               if ( xBindResult != 0 )\r
+               {\r
+                       FreeRTOS_printf( ( "FreeRTOS_bind() failed\n" ) );\r
+                       return xBindResult;\r
+               }\r
 \r
                #if( ipconfigFTP_TX_BUFSIZE > 0 )\r
                {\r