Skip to content

Commit

Permalink
wolfSSH Client
Browse files Browse the repository at this point in the history
1. In the windowMonitor(), move the check for quit outside the
   conditional build so it works for both macOS and Linux.
2. Removed a dead store in readPeer(). If the socket wants read, that's
   fine. Don't need to override it.
3. When allocating memory for the hostname, don't forget the nul.
4. When parsing the command line and storing a copy of it to send to the
   peer, stash it in the config.
  • Loading branch information
ejohnstown committed Sep 20, 2023
1 parent 37bc954 commit 95659fc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/wolfssh/wolfssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ static THREAD_RET windowMonitor(void* in)
do {
#if (defined(__OSX__) || defined(__APPLE__))
dispatch_semaphore_wait(windowSem, DISPATCH_TIME_FOREVER);
if (args->quit) {
break;
}
#else
sem_wait(&windowSem);
#endif
if (args->quit) {
break;
}
ret = sendCurrentWindowSize(args);
(void)ret;
} while (1);
Expand Down Expand Up @@ -375,7 +375,7 @@ static THREAD_RET readPeer(void* in)
if (ret == WS_FATAL_ERROR) {
ret = wolfSSH_get_error(args->ssh);
if (ret == WS_WANT_READ) {
ret = WS_SUCCESS;
continue;
}
#ifdef WOLFSSH_AGENT
else if (ret == WS_CHAN_RXD) {
Expand Down Expand Up @@ -726,7 +726,7 @@ static int config_parse_command_line(struct config* config,
if (found != NULL) {
*found = '\0';
sz = strlen(cursor);
config->hostname = (char*)malloc(sz);
config->hostname = (char*)malloc(sz + 1);
strcpy(config->hostname, cursor);
cursor = found + 1;
if (*cursor != 0) {
Expand All @@ -736,7 +736,7 @@ static int config_parse_command_line(struct config* config,
}
else {
sz = strlen(cursor);
config->hostname = (char*)malloc(sz);
config->hostname = (char*)malloc(sz + 1);
strcpy(config->hostname, cursor);
}

Expand All @@ -758,6 +758,7 @@ static int config_parse_command_line(struct config* config,
}

command = (char*)malloc(commandSz);
config->command = command;
cursor = command;

for (i = myoptind; i < argc; i++) {
Expand Down

0 comments on commit 95659fc

Please sign in to comment.