Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cli-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,17 @@ void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
if (!ses.init_done) {
snprintf(fullmsg, sizeof(fullmsg), "Exited: %s", exitmsg);
} else {
snprintf(fullmsg, sizeof(fullmsg),
if (strchr(cli_opts.remotehost, ':') != NULL) {
snprintf(fullmsg, sizeof(fullmsg),
"Connection to %s@[%s]:%s exited: %s",
cli_opts.username, cli_opts.remotehost,
cli_opts.remoteport, exitmsg);
} else {
snprintf(fullmsg, sizeof(fullmsg),
"Connection to %s@%s:%s exited: %s",
cli_opts.username, cli_opts.remotehost,
cli_opts.remoteport, exitmsg);
}
}

/* Do the cleanup first, since then the terminal will be reset */
Expand Down
14 changes: 12 additions & 2 deletions src/svr-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ static void main_inetd() {
if (svr_opts.reexec_childpipe < 0) {
/* In case our inetd was lax in logging source addresses */
get_socket_address(0, NULL, NULL, &host, &port, 0);
dropbear_log(LOG_INFO, "Child connection from %s:%s", host, port);
if (strchr(host, ':') != NULL) {
dropbear_log(LOG_INFO, "Child connection from [%s]:%s", host, port);
} else {
dropbear_log(LOG_INFO, "Child connection from %s:%s", host, port);
}

m_free(host);
m_free(port);

Expand Down Expand Up @@ -326,7 +331,12 @@ static void main_noinetd(int argc, char ** argv, const char* multipath) {

/* child */
getaddrstring(&remoteaddr, NULL, &remote_port, 0);
dropbear_log(LOG_INFO, "Child connection from %s:%s", remote_host, remote_port);
if (strchr(remote_host, ':') != NULL) {
dropbear_log(LOG_INFO, "Child connection from [%s]:%s", remote_host, remote_port);
} else {
dropbear_log(LOG_INFO, "Child connection from %s:%s", remote_host, remote_port);
}

m_free(remote_host);
m_free(remote_port);

Expand Down
7 changes: 6 additions & 1 deletion src/svr-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ void svr_session(int sock, int childpipe) {
get_socket_address(ses.sock_in, NULL, NULL, &host, &port, 0);
len = strlen(host) + strlen(port) + 2;
svr_ses.addrstring = m_malloc(len);
snprintf(svr_ses.addrstring, len, "%s:%s", host, port);
/* bracket is needed if it's IPv6 address */
if (strchr(host, ':') != NULL) {
snprintf(svr_ses.addrstring, len, "[%s]:%s", host, port);
} else {
snprintf(svr_ses.addrstring, len, "%s:%s", host, port);
}
Comment on lines +125 to +129

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like indentation isn't right here, should be tabs.

m_free(host);
m_free(port);

Expand Down