Skip to content

Commit 4ff4fac

Browse files
committed
Fix DoDisconnect to signal connection termination
DoDisconnect was returning WS_SUCCESS after receiving SSH_MSG_DISCONNECT, allowing the session to continue processing packets. Per RFC 4253 §11.1, no further data should be accepted after a disconnect message. Add new WS_DISCONNECT error code and return it from DoDisconnect so callers tear down the connection immediately. F-605
1 parent 16902b0 commit 4ff4fac

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/internal.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ const char* GetErrorString(int err)
491491
case WS_KDF_E:
492492
return "KDF error";
493493

494+
case WS_DISCONNECT:
495+
return "peer sent disconnect";
496+
494497
default:
495498
return "Unknown error code";
496499
}
@@ -6475,7 +6478,6 @@ static int DoDisconnect(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
64756478
const char* reasonStr = NULL;
64766479
word32 begin = *idx;
64776480

6478-
WOLFSSH_UNUSED(ssh);
64796481
WOLFSSH_UNUSED(len);
64806482
WOLFSSH_UNUSED(reasonStr);
64816483

@@ -6524,7 +6526,8 @@ static int DoDisconnect(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
65246526

65256527
*idx = begin;
65266528

6527-
return WS_SUCCESS;
6529+
ssh->error = WS_DISCONNECT;
6530+
return WS_DISCONNECT;
65286531
}
65296532

65306533

wolfssh/error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ enum WS_ErrorCodes {
136136
WS_ED25519_E = -1095, /* Ed25519 failure */
137137
WS_AUTH_PENDING = -1096, /* User authentication still pending */
138138
WS_KDF_E = -1097, /* KDF error*/
139+
WS_DISCONNECT = -1098, /* peer sent disconnect */
139140

140-
WS_LAST_E = WS_KDF_E /* Update this to indicate last error */
141+
WS_LAST_E = WS_DISCONNECT /* Update this to indicate last error */
141142
};
142143

143144

0 commit comments

Comments
 (0)