Skip to content

Commit 0387a36

Browse files
committed
MakeUpperPtr should use length from ArgSlice instead of mistaken bytesRead calculation.
1 parent e307c3e commit 0387a36

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

libs/server/Resp/Objects/ObjectStoreUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public OperationDirection GetOperationDirection(ArgSlice input)
114114
if (input.ReadOnlySpan.SequenceEqual("RIGHT"u8))
115115
return OperationDirection.Right;
116116
// Rare case: try making upper case and retry
117-
MakeUpperCase(input.ptr);
117+
MakeUpperCase(input.ptr, input.length);
118118
if (input.ReadOnlySpan.SequenceEqual("LEFT"u8))
119119
return OperationDirection.Left;
120120
if (input.ReadOnlySpan.SequenceEqual("RIGHT"u8))

libs/server/Resp/Parser/RespCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,7 @@ private RespCommand ArrayParseCommand(bool writeErrorOnFailure, ref int count, r
27682768
var ptr = recvBufferPtr + readHead;
27692769

27702770
// See if input command is all upper-case. If not, convert and try fast parse pass again.
2771-
if (MakeUpperCase(ptr))
2771+
if (MakeUpperCase(ptr, bytesRead - readHead))
27722772
{
27732773
cmd = FastParseCommand(out count);
27742774
if (cmd != RespCommand.NONE)

libs/server/Resp/RespServerSession.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ private void ProcessMessages()
657657
}
658658

659659
// Make first command in string as uppercase
660-
private bool MakeUpperCase(byte* ptr)
660+
private bool MakeUpperCase(byte* ptr, int len)
661661
{
662662
// Assume most commands are already upper case.
663663
// Assume most commands are 2-8 bytes long.
@@ -672,7 +672,6 @@ private bool MakeUpperCase(byte* ptr)
672672
// Note that _all_ of these bytes are <= 95 in the common case
673673
// and there's no need to scan the whole string in those cases.
674674

675-
var len = bytesRead - readHead;
676675
if (len >= 12)
677676
{
678677
var cmdLen = (uint)(*(ptr + 5) - '2');

0 commit comments

Comments
 (0)