mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-10 06:23:01 +03:00
misc: Fix format truncation in ssh_path_expand_escape()
error: ‘%u’ directive output may be truncated writing between 1 and 10
bytes into a region of size 6.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 20406e51c9
)
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Jakub Jelen
parent
ea075e3f2e
commit
fd1add66cf
@@ -219,7 +219,7 @@ struct ssh_session_struct {
|
||||
char *custombanner;
|
||||
unsigned long timeout; /* seconds */
|
||||
unsigned long timeout_usec;
|
||||
unsigned int port;
|
||||
uint16_t port;
|
||||
socket_t fd;
|
||||
int StrictHostKeyChecking;
|
||||
char compressionlevel;
|
||||
|
13
src/misc.c
13
src/misc.c
@@ -1164,14 +1164,13 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
|
||||
x = strdup(session->opts.username);
|
||||
break;
|
||||
case 'p':
|
||||
if (session->opts.port < 65536) {
|
||||
char tmp[6];
|
||||
if (session->opts.port > 0) {
|
||||
char tmp[6];
|
||||
|
||||
snprintf(tmp,
|
||||
sizeof(tmp),
|
||||
"%u",
|
||||
session->opts.port > 0 ? session->opts.port : 22);
|
||||
x = strdup(tmp);
|
||||
snprintf(tmp, sizeof(tmp), "%hu",
|
||||
(uint16_t)(session->opts.port > 0 ? session->opts.port
|
||||
: 22));
|
||||
x = strdup(tmp);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user