feat: add pedantic subject validation and max payload enforcement on PUB
Move max payload validation from the parser to ProcessPubAsync so the server sends -ERR 'Maximum Payload Violation' and closes the connection (matching Go reference client.go:2442). In pedantic mode, reject PUB with wildcard subjects via -ERR 'Invalid Publish Subject' (client.go:2869). Add disposed guard to SubList.Remove to prevent crash during shutdown.
This commit is contained in:
@@ -203,10 +203,10 @@ public sealed class NatsParser
|
||||
throw new ProtocolViolationException("Invalid PUB arguments");
|
||||
}
|
||||
|
||||
if (size < 0 || size > _maxPayload)
|
||||
if (size < 0)
|
||||
throw new ProtocolViolationException("Invalid payload size");
|
||||
|
||||
// Now read payload + \r\n
|
||||
// Now read payload + \r\n (max payload enforcement is done at the client level)
|
||||
buffer = buffer.Slice(afterLine);
|
||||
_awaitingPayload = true;
|
||||
_expectedPayloadSize = size;
|
||||
@@ -253,7 +253,7 @@ public sealed class NatsParser
|
||||
throw new ProtocolViolationException("Invalid HPUB arguments");
|
||||
}
|
||||
|
||||
if (hdrSize < 0 || totalSize < 0 || hdrSize > totalSize || totalSize > _maxPayload)
|
||||
if (hdrSize < 0 || totalSize < 0 || hdrSize > totalSize)
|
||||
throw new ProtocolViolationException("Invalid HPUB sizes");
|
||||
|
||||
buffer = buffer.Slice(afterLine);
|
||||
|
||||
Reference in New Issue
Block a user