mirror of
https://github.com/clearml/dropbear
synced 2025-06-26 18:17:32 +00:00
Fix error handling for dbclient async connect
This commit is contained in:
parent
20d970a0e2
commit
5dff74109e
@ -87,6 +87,7 @@ int main(int argc, char ** argv) {
|
|||||||
static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
|
static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
|
||||||
|
|
||||||
char fmtbuf[300];
|
char fmtbuf[300];
|
||||||
|
char exitmsg[500];
|
||||||
|
|
||||||
if (!sessinitdone) {
|
if (!sessinitdone) {
|
||||||
snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s",
|
snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s",
|
||||||
@ -98,12 +99,15 @@ static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
|
|||||||
cli_opts.remoteport, format);
|
cli_opts.remoteport, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Arguments to the exit printout may be unsafe to use after session_cleanup() */
|
||||||
|
vsnprintf(exitmsg, sizeof(exitmsg), fmtbuf, param);
|
||||||
|
|
||||||
/* Do the cleanup first, since then the terminal will be reset */
|
/* Do the cleanup first, since then the terminal will be reset */
|
||||||
session_cleanup();
|
session_cleanup();
|
||||||
/* Avoid printing onwards from terminal cruft */
|
/* Avoid printing onwards from terminal cruft */
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
_dropbear_log(LOG_INFO, fmtbuf, param);
|
dropbear_log(LOG_INFO, "%s", exitmsg);;
|
||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
netio.c
4
netio.c
@ -104,6 +104,8 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
|
|||||||
message.msg_iovlen = iovlen;
|
message.msg_iovlen = iovlen;
|
||||||
res = sendmsg(c->sock, &message, MSG_FASTOPEN);
|
res = sendmsg(c->sock, &message, MSG_FASTOPEN);
|
||||||
if (res < 0 && errno != EINPROGRESS) {
|
if (res < 0 && errno != EINPROGRESS) {
|
||||||
|
m_free(c->errstring);
|
||||||
|
c->errstring = m_strdup(strerror(errno));
|
||||||
/* Not entirely sure which kind of errors are normal - 2.6.32 seems to
|
/* Not entirely sure which kind of errors are normal - 2.6.32 seems to
|
||||||
return EPIPE for any (nonblocking?) sendmsg(). just fall back */
|
return EPIPE for any (nonblocking?) sendmsg(). just fall back */
|
||||||
TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
|
TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
|
||||||
@ -124,6 +126,8 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
|
|||||||
|
|
||||||
if (res < 0 && errno != EINPROGRESS) {
|
if (res < 0 && errno != EINPROGRESS) {
|
||||||
/* failure */
|
/* failure */
|
||||||
|
m_free(c->errstring);
|
||||||
|
c->errstring = m_strdup(strerror(errno));
|
||||||
close(c->sock);
|
close(c->sock);
|
||||||
c->sock = -1;
|
c->sock = -1;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user