mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-18 07:23:24 +09:00
[MG_Remote, MG_Test, ci] (P7): the token compare runs a fixed 64-byte width, an ignored window ask is logged once, a nonce that could not be minted is refused by name, and a garbage first frame while busy is MalformedHello rather than Busy
- AuthToken.h: ConstantTimeTokenMatch loops kAuthTokenCompareBytes (64) iterations with both operands read as zero past their ends - its trip count no longer tells a peer the configured token's length; a token longer than 64 is still compared to its last byte (SocketTransportTest pins the 70-byte case)
- ServerSession.cpp: an ask in Hello.linkTerms above the granted terms logs one MGLOG_W naming both sides ("the ask is ignored and the session is server-sized"); the production client asks for nothing, so a session that was never mis-configured never logs it; SessionHandshakeTest's 64 GiB case requires the line (red before: absent)
- ServerSession.cpp: a MintNonce failure sends Refuse{LinkTerms} "stream data plane unavailable: the server could not mint a data nonce" before returning the fault it is (still exit 67, still counted) instead of a bare close
- ServerMain.cpp: a first frame with the wrong magic or over 1 MiB while a session is live is Refuse{MalformedHello} "first frame is not a control frame", drained before the close so the refusal is not RST away; Busy stays the answer for a well-formed frame that is not a DataBind
- tcp_supervisor_smoke.py: garbage_first_frame_while_busy (magic XXXX on a live session -> code 8; red before: code 7)
- fatal census unchanged: 79 abort sites, 3 refusal words (the new refusals go through the enum, not a literal)
This commit is contained in:
@@ -89,10 +89,29 @@ void RefuseBusy(SocketTransport& transport, const char* detail) {
|
||||
constexpr std::uint32_t kFirstFrameWaitMs = 2000;
|
||||
constexpr std::uint64_t kFirstFrameMaxBytes = 1024 * 1024;
|
||||
|
||||
// Whatever the peer has already sent, read and dropped (non-blocking, at most 1 MiB), so a close
|
||||
// with bytes still unread does not become an RST that discards the refusal in flight - the
|
||||
// reason RefuseBusy reads the Hello before refusing.
|
||||
void DrainUnread(int fd) {
|
||||
char sink[4096];
|
||||
for (int rounds = 0; rounds < 256; ++rounds) {
|
||||
if (::recv(fd, sink, sizeof(sink), MSG_DONTWAIT) <= 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
void RouteWhileBusy(SocketTransport& connection, int handoff) {
|
||||
std::vector<std::uint8_t> frame;
|
||||
const int fd = connection.StreamFd();
|
||||
const auto read = SocketTransport::ReceiveOneFrame(fd, kFirstFrameWaitMs, kFirstFrameMaxBytes, &frame);
|
||||
if (read == MOBILEGL_ERR_PROTOCOL_MISMATCH) {
|
||||
// (F fix round) A first frame with the wrong magic or a length over 1 MiB is not a second
|
||||
// client waiting its turn; it is not a control frame at all, and Busy would name a
|
||||
// condition this connection does not have. The word is the one ServerSession::Accept uses
|
||||
// for a first frame that is not a verifiable Hello.
|
||||
DrainUnread(fd);
|
||||
Refuse(connection, Protocol::RefuseCode::MalformedHello, "first frame is not a control frame");
|
||||
return;
|
||||
}
|
||||
std::uint8_t nonce[kDataNonceBytes] = {};
|
||||
if (read == MOBILEGL_OK && DecodeDataBind(frame, nonce)) {
|
||||
if (handoff >= 0 &&
|
||||
|
||||
Reference in New Issue
Block a user