File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -780,6 +780,11 @@ int main(int argc, char** argv)
780780
781781 case 'p' :
782782 if (ret == WS_SUCCESS ) {
783+ if (myoptarg == NULL ) {
784+ ret = WS_BAD_ARGUMENT ;
785+ break ;
786+ }
787+
783788 ret = XATOI (myoptarg );
784789 if (ret < 0 ) {
785790 fprintf (stderr , "Issue parsing port number %s\n" ,
Original file line number Diff line number Diff line change @@ -747,7 +747,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
747747 if (agentListenFd > maxFd )
748748 maxFd = agentListenFd ;
749749 }
750- if (threadCtx -> agentCbCtx .state == AGENT_STATE_CONNECTED ) {
750+ if (agentFd >= 0 && threadCtx -> agentCbCtx .state == AGENT_STATE_CONNECTED ) {
751751 FD_SET (agentFd , & readFds );
752752 if (agentFd > maxFd )
753753 maxFd = agentFd ;
@@ -759,7 +759,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
759759 if (fwdListenFd > maxFd )
760760 maxFd = fwdListenFd ;
761761 }
762- if (threadCtx -> fwdCbCtx .state == FWD_STATE_CONNECTED ) {
762+ if (fwdFd >= 0 && threadCtx -> fwdCbCtx .state == FWD_STATE_CONNECTED ) {
763763 FD_SET (fwdFd , & readFds );
764764 if (fwdFd > maxFd )
765765 maxFd = fwdFd ;
@@ -918,7 +918,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
918918 }
919919 #endif
920920 #ifdef WOLFSSH_AGENT
921- if (threadCtx -> agentCbCtx .state == AGENT_STATE_CONNECTED ) {
921+ if (agentFd >= 0 && threadCtx -> agentCbCtx .state == AGENT_STATE_CONNECTED ) {
922922 if (FD_ISSET (agentFd , & readFds )) {
923923 #ifdef SHELL_DEBUG
924924 printf ("agentFd set in readfd\n" );
@@ -979,7 +979,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
979979 }
980980 #endif
981981 #ifdef WOLFSSH_FWD
982- if (threadCtx -> fwdCbCtx .state == FWD_STATE_CONNECTED ) {
982+ if (fwdFd >= 0 && threadCtx -> fwdCbCtx .state == FWD_STATE_CONNECTED ) {
983983 if (FD_ISSET (fwdFd , & readFds )) {
984984 #ifdef SHELL_DEBUG
985985 printf ("fwdFd set in readfd\n" );
Original file line number Diff line number Diff line change @@ -271,6 +271,8 @@ THREAD_RETURN WOLFSSH_THREAD portfwd_worker(void* args)
271271 break ;
272272
273273 case 'p' :
274+ if (myoptarg == NULL )
275+ err_sys ("null argument found" );
274276 port = (word16 )atoi (myoptarg );
275277 #if !defined(NO_MAIN_DRIVER ) || defined(USE_WINDOWS_API )
276278 if (port == 0 )
Original file line number Diff line number Diff line change @@ -277,6 +277,9 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
277277 break ;
278278
279279 case 'p' :
280+ if (myoptarg == NULL )
281+ err_sys ("null argument found" );
282+
280283 port = (word16 )atoi (myoptarg );
281284 #if !defined(NO_MAIN_DRIVER ) || defined(USE_WINDOWS_API )
282285 if (port == 0 )
Original file line number Diff line number Diff line change @@ -1361,6 +1361,8 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
13611361 break ;
13621362
13631363 case 'p' :
1364+ if (myoptarg == NULL )
1365+ err_sys ("null argument found" );
13641366 port = (word16 )atoi (myoptarg );
13651367 #if !defined(NO_MAIN_DRIVER ) || defined(USE_WINDOWS_API )
13661368 if (port == 0 )
You can’t perform that action at this time.
0 commit comments