@@ -1524,10 +1524,8 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
15241524 argsCount = 0 ;
15251525 args [argsCount ++ ] = "." ;
15261526 args [argsCount ++ ] = "-1" ;
1527- #ifndef USE_WINDOWS_API
15281527 args [argsCount ++ ] = "-p" ;
15291528 args [argsCount ++ ] = "0" ;
1530- #endif
15311529 ser .argv = (char * * )args ;
15321530 ser .argc = argsCount ;
15331531 ser .signal = & ready ;
@@ -1709,8 +1707,12 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
17091707 }
17101708
17111709 argsCount = wolfSSH_shutdown (ssh );
1712- if (argsCount == WS_SOCKET_ERROR_E ) {
1713- /* If the socket is closed on shutdown, peer is gone, this is OK. */
1710+ if (argsCount == WS_SOCKET_ERROR_E ||
1711+ (argsCount == WS_ERROR &&
1712+ wolfSSH_get_error (ssh ) == WS_SOCKET_ERROR_E )) {
1713+ /* If the socket is closed on shutdown, peer is gone, this is OK. On
1714+ * Windows the recv path returns generic WS_FATAL_ERROR with the specific
1715+ * code stashed in wolfSSH_get_error. */
17141716 argsCount = WS_SUCCESS ;
17151717 }
17161718
@@ -1734,6 +1736,7 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
17341736 k_sleep (Z_TIMEOUT_TICKS (100 ));
17351737#endif
17361738 ThreadJoin (serThread );
1739+ FreeTcpReady (& ready );
17371740}
17381741
17391742
@@ -1794,10 +1797,8 @@ static void test_wolfSSH_SFTP_PartialSend(void)
17941797 argsCount = 0 ;
17951798 args [argsCount ++ ] = "." ;
17961799 args [argsCount ++ ] = "-1" ;
1797- #ifndef USE_WINDOWS_API
17981800 args [argsCount ++ ] = "-p" ;
17991801 args [argsCount ++ ] = "0" ;
1800- #endif
18011802 ser .argv = (char * * )args ;
18021803 ser .argc = argsCount ;
18031804 ser .signal = & ready ;
@@ -1984,7 +1985,11 @@ static void test_wolfSSH_SFTP_PartialSend(void)
19841985 }
19851986
19861987 argsCount = wolfSSH_shutdown (ssh );
1987- if (argsCount == WS_SOCKET_ERROR_E ) {
1988+ /* Benign peer reset: WS_SOCKET_ERROR_E either as the return (send path) or in
1989+ * wolfSSH_get_error while shutdown returns generic WS_FATAL_ERROR (recv path). */
1990+ if (argsCount == WS_SOCKET_ERROR_E ||
1991+ (argsCount == WS_ERROR &&
1992+ wolfSSH_get_error (ssh ) == WS_SOCKET_ERROR_E )) {
19881993 argsCount = WS_SUCCESS ;
19891994 }
19901995#if DEFAULT_HIGHWATER_MARK < 8000
@@ -2003,6 +2008,7 @@ static void test_wolfSSH_SFTP_PartialSend(void)
20032008 k_sleep (Z_TIMEOUT_TICKS (100 ));
20042009#endif
20052010 ThreadJoin (serThread );
2011+ FreeTcpReady (& ready );
20062012#endif /* WOLFSSH_TEST_INTERNAL */
20072013}
20082014
@@ -2034,10 +2040,8 @@ static void sftp_rekey_test(int nonBlock)
20342040 argsCount = 0 ;
20352041 args [argsCount ++ ] = "." ;
20362042 args [argsCount ++ ] = "-1" ;
2037- #ifndef USE_WINDOWS_API
20382043 args [argsCount ++ ] = "-p" ;
20392044 args [argsCount ++ ] = "0" ;
2040- #endif
20412045 ser .argv = (char * * )args ;
20422046 ser .argc = argsCount ;
20432047 ser .signal = & ready ;
@@ -2121,7 +2125,11 @@ static void sftp_rekey_test(int nonBlock)
21212125 * before the WS_REKEYING fixup below could otherwise mask it. The loop cap
21222126 * is one above the assert threshold to leave last-iteration headroom. */
21232127 AssertIntLE (tries , SFTP_REKEY_MAX_TRIES );
2124- if (argsCount == WS_SOCKET_ERROR_E ) {
2128+ /* Benign peer reset: WS_SOCKET_ERROR_E either as the return (send path) or in
2129+ * wolfSSH_get_error while shutdown returns generic WS_FATAL_ERROR (recv path). */
2130+ if (argsCount == WS_SOCKET_ERROR_E ||
2131+ (argsCount == WS_ERROR &&
2132+ wolfSSH_get_error (ssh ) == WS_SOCKET_ERROR_E )) {
21252133 argsCount = WS_SUCCESS ;
21262134 }
21272135#if DEFAULT_HIGHWATER_MARK < 8000
@@ -2141,6 +2149,7 @@ static void sftp_rekey_test(int nonBlock)
21412149 k_sleep (Z_TIMEOUT_TICKS (100 ));
21422150#endif
21432151 ThreadJoin (serThread );
2152+ FreeTcpReady (& ready );
21442153}
21452154
21462155static void test_wolfSSH_SFTP_ReKey (void )
@@ -2319,10 +2328,8 @@ static void test_wolfSSH_SFTP_Confinement(void)
23192328 argsCount = 0 ;
23202329 args [argsCount ++ ] = "." ;
23212330 args [argsCount ++ ] = "-1" ;
2322- #ifndef USE_WINDOWS_API
23232331 args [argsCount ++ ] = "-p" ;
23242332 args [argsCount ++ ] = "0" ;
2325- #endif
23262333 ser .argv = (char * * )args ;
23272334 ser .argc = argsCount ;
23282335 ser .signal = & ready ;
@@ -2513,6 +2520,7 @@ static void test_wolfSSH_SFTP_Confinement(void)
25132520 k_sleep (Z_TIMEOUT_TICKS (100 ));
25142521#endif
25152522 ThreadJoin (serThread );
2523+ FreeTcpReady (& ready );
25162524
25172525 /* remove staged targets; escMkdir/escDest only exist if confinement
25182526 * leaked, and inJailDir only if the positive-case RMDIR did not run, so
@@ -2834,10 +2842,8 @@ static void scp_rekey_test(int nonBlock, int toServer)
28342842 argsCount = 0 ;
28352843 args [argsCount ++ ] = "." ;
28362844 args [argsCount ++ ] = "-1" ;
2837- #ifndef USE_WINDOWS_API
28382845 args [argsCount ++ ] = "-p" ;
28392846 args [argsCount ++ ] = "0" ;
2840- #endif
28412847 ser .argv = (char * * )args ;
28422848 ser .argc = argsCount ;
28432849 ser .signal = & ready ;
@@ -2932,6 +2938,7 @@ static void scp_rekey_test(int nonBlock, int toServer)
29322938 wolfSSH_free (ssh );
29332939 wolfSSH_CTX_free (ctx );
29342940 ThreadJoin (serThread );
2941+ FreeTcpReady (& ready );
29352942
29362943 /* verify the transferred file matches the source once the server is done */
29372944 AssertIntEQ (scpFilesMatch (verifyName , fileData , SCP_REKEY_FILE_SZ ), 0 );
@@ -3648,10 +3655,8 @@ static void test_wolfSSH_KeyboardInteractive(void)
36483655 args [argsCount ++ ] = "-1" ;
36493656 args [argsCount ++ ] = "-i" ;
36503657 args [argsCount ++ ] = "test:test" ;
3651- #ifndef USE_WINDOWS_API
36523658 args [argsCount ++ ] = "-p" ;
36533659 args [argsCount ++ ] = "0" ;
3654- #endif
36553660 ser .argv = (char * * )args ;
36563661 ser .argc = argsCount ;
36573662 ser .signal = & ready ;
@@ -3665,8 +3670,12 @@ static void test_wolfSSH_KeyboardInteractive(void)
36653670
36663671
36673672 argsCount = wolfSSH_shutdown (ssh );
3668- if (argsCount == WS_SOCKET_ERROR_E ) {
3669- /* If the socket is closed on shutdown, peer is gone, this is OK. */
3673+ if (argsCount == WS_SOCKET_ERROR_E ||
3674+ (argsCount == WS_ERROR &&
3675+ wolfSSH_get_error (ssh ) == WS_SOCKET_ERROR_E )) {
3676+ /* If the socket is closed on shutdown, peer is gone, this is OK. On
3677+ * Windows the recv path returns generic WS_FATAL_ERROR with the specific
3678+ * code stashed in wolfSSH_get_error. */
36703679 argsCount = WS_SUCCESS ;
36713680 }
36723681
@@ -3690,6 +3699,7 @@ static void test_wolfSSH_KeyboardInteractive(void)
36903699 k_sleep (Z_TIMEOUT_TICKS (100 ));
36913700#endif
36923701 ThreadJoin (serThread );
3702+ FreeTcpReady (& ready );
36933703}
36943704
36953705#else /* WOLFSSH_SFTP && !NO_WOLFSSH_CLIENT && !SINGLE_THREADED */
@@ -3708,6 +3718,8 @@ int wolfSSH_ApiTest(int argc, char** argv)
37083718#ifdef WOLFSSH_TEST_BLOCK
37093719 return 77 ;
37103720#else
3721+ WSTARTTCP ();
3722+
37113723 AssertIntEQ (wolfSSH_Init (), WS_SUCCESS );
37123724
37133725 #if defined(FIPS_VERSION_GE ) && FIPS_VERSION_GE (5 ,2 )
0 commit comments