Skip to content
Prev Previous commit
Next Next commit
soundness fix
  • Loading branch information
dkz2 committed May 26, 2023
commit c2e44ec8fe980256bea4639ff0ffc6a3ebb649d3
1 change: 0 additions & 1 deletion Sources/SwiftMemcache/MemcachedResponseDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct MemcachedResponseDecoder: ByteToMessageDecoder {
preconditionFailure("Response code could not be read.")
}


// Check if there's a whitespace character, this indicates flags are present
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only flags but also datalen. Just invert the comment to say if there is not a whitespace then we are at the end of the line.

if buffer.readableBytes > 2, buffer.getInteger(at: buffer.readerIndex, as: UInt8.self) == UInt8.whitespace {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just read the next byte here and then base our decision of that. Also return needMoreData if there is not a single byte readable.

buffer.moveReaderIndex(forwardBy: 1)
Expand Down