GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix missing readable-bytes check in SmtpResponseDecoder (#17516) · netty/netty@91a8497

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-smtp/src
    • main/java/io/netty/handler/codec/smtp
      • SmtpResponseDecoder.java
    • test/java/io/netty/handler/codec/smtp
      • SmtpResponseDecoderTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java‎

Copy file name to clipboardExpand all lines: codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected SmtpResponse decode(ChannelHandlerContext ctx, ByteBuf buffer) throws
8181
try {
8282
final int readable = frame.readableBytes();
8383
final int readerIndex = frame.readerIndex();
84-
if (readable < 3) {
84+
if (readable < 4) {
8585
reset();
8686
throw newDecoderException(buffer, readerIndex, readable);
8787
}
Collapse file

‎codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java‎

Copy file name to clipboardExpand all lines: codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ public void execute() {
134134
});
135135
}
136136

137+
@Test
138+
public void testDecodeLineWithOnlyCodeAndNoSeparator() {
139+
final EmbeddedChannel channel = newChannel();
140+
// A line consisting of just the 3-digit code (no separator, no detail) must be rejected as an invalid
141+
// line rather than crash the decoder: ByteToMessageDecoder wraps any *unexpected* exception thrown out
142+
// of decode() (e.g. an IndexOutOfBoundsException from reading past the line) into a DecoderException
143+
// with that exception as its cause, whereas the intentional "invalid line" rejection path throws a
144+
// DecoderException with no cause. Asserting there is no cause distinguishes the two.
145+
DecoderException exception = assertThrows(DecoderException.class, new Executable() {
146+
@Override
147+
public void execute() {
148+
channel.writeInbound(newBuffer("250\r\n"));
149+
}
150+
});
151+
assertNull(exception.getCause());
152+
channel.finishAndReleaseAll();
153+
}
154+
137155
@Test
138156
public void testDecodeInvalidLine() {
139157
final EmbeddedChannel channel = newChannel();

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.