Skip to content

Commit 16cf193

Browse files
examples/portfwd: drop the password from the options banner
- The startup banner prints ssh host, username and the two forward endpoints; the password line and its argument are gone. - userPassword has internal linkage, and portfwd_worker() zeroes it with wc_ForceZero() as soon as wolfSSH_connect() returns, on both the success and the failure path. - portfwd.c includes wolfssl/wolfcrypt/memory.h. Issue: F-11673
1 parent 9777bc5 commit 16cf193

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

examples/portfwd/portfwd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <wolfssh/test.h>
4545
#include <wolfssh/port.h>
4646
#include <wolfssl/wolfcrypt/ecc.h>
47+
#include <wolfssl/wolfcrypt/memory.h>
4748

4849
#ifndef NO_WOLFSSH_CLIENT
4950
#include "examples/portfwd/wolfssh_portfwd.h"
@@ -181,7 +182,7 @@ static int SetEcho(int on)
181182
}
182183

183184

184-
byte userPassword[256];
185+
static byte userPassword[256];
185186

186187

187188
static int wsUserAuth(byte authType,
@@ -535,10 +536,9 @@ THREAD_RETURN WOLFSSH_THREAD portfwd_worker(void* args)
535536
printf("portfwd options\n"
536537
" * ssh host: %s:%u\n"
537538
" * username: %s\n"
538-
" * password: %s\n"
539539
" * forward from: %s:%u\n"
540540
" * forward to: %s:%u\n",
541-
host, port, username, password ? password : "",
541+
host, port, username,
542542
fwdFromHost, fwdFromPort,
543543
fwdToHost, fwdToPort);
544544

@@ -622,6 +622,8 @@ THREAD_RETURN WOLFSSH_THREAD portfwd_worker(void* args)
622622
err_sys("Couldn't set the session's socket.");
623623

624624
ret = wolfSSH_connect(ssh);
625+
/* User authentication is done with the buffer either way. */
626+
wc_ForceZero(userPassword, sizeof(userPassword));
625627
if (ret != WS_SUCCESS)
626628
err_sys("Couldn't connect SFTP");
627629

0 commit comments

Comments
 (0)