Repository: microsoft/garnet
File: libs/server/Resp/Objects/ListCommands.cs (C#)

Code before:

            if (NetworkMultiKeySlotVerify(readOnly: false, firstKey: 1, lastKey: numKeys + 1))
                return true;

            ArgSlice dir = default;

            if (!RespReadUtils.ReadPtrWithLengthHeader(ref dir.ptr, ref dir.length, ref ptr, recvBufferPtr + bytesRead))
                return false;

            var popDirection = GetOperationDirection(dir);

            if (popDirection == OperationDirection.Unknown)
            {
                return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
            }

            int popCount = 1;

            if (count == numKeys + 4)
            {
                ArgSlice countArg = default;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref countArg.ptr, ref countArg.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!countArg.ReadOnlySpan.SequenceEqual("COUNT"u8))
                {
                    return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
                }

                // Read count
                if (!RespReadUtils.ReadIntWithLengthHeader(out popCount, ref ptr, recvBufferPtr + bytesRead)) return false;
            }

            GarnetStatus statusOp; ArgSlice key; ArgSlice[] elements;

            if (popDirection == OperationDirection.Left)
            {
                statusOp = storageApi.ListLeftPop(keys, popCount, out key, out elements);
            }
            else
            {
                statusOp = storageApi.ListRightPop(keys, popCount, out key, out elements);
            }

            switch (statusOp)
            {
                case GarnetStatus.OK:
                    while (!RespWriteUtils.WriteArrayLength(2, ref dcurr, dend))
                        SendAndReset();


Review comment (security):
Please replace with: 
```if (!countArg.ReadOnlySpan.EqualsUpperCaseSpanIgnoringCase(CmdStrings.COUNT))```
(so that this check is not case-sensitive)

Code after:

            if (NetworkMultiKeySlotVerify(readOnly: false, firstKey: 1, lastKey: numKeys + 1))
                return true;

            ArgSlice dir = default;

            if (!RespReadUtils.ReadPtrWithLengthHeader(ref dir.ptr, ref dir.length, ref ptr, recvBufferPtr + bytesRead))
                return false;

            var popDirection = GetOperationDirection(dir);

            if (popDirection == OperationDirection.Unknown)
            {
                return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
            }

            int popCount = 1;

            if (count == numKeys + 4)
            {
                ArgSlice countArg = default;

                if (!RespReadUtils.ReadPtrWithLengthHeader(ref countArg.ptr, ref countArg.length, ref ptr, recvBufferPtr + bytesRead))
                    return false;

                if (!countArg.ReadOnlySpan.EqualsUpperCaseSpanIgnoringCase(CmdStrings.COUNT))
                {
                    return AbortWithErrorMessage(count, CmdStrings.RESP_ERR_GENERIC_SYNTAX_ERROR);
                }

                // Read count
                if (!RespReadUtils.ReadIntWithLengthHeader(out popCount, ref ptr, recvBufferPtr + bytesRead)) return false;
            }

            GarnetStatus statusOp; ArgSlice key; ArgSlice[] elements;

            if (popDirection == OperationDirection.Left)
            {
                statusOp = storageApi.ListLeftPop(keys, popCount, out key, out elements);
            }
            else
            {
                statusOp = storageApi.ListRightPop(keys, popCount, out key, out elements);
            }

            switch (statusOp)
            {
                case GarnetStatus.OK:
                    while (!RespWriteUtils.WriteArrayLength(2, ref dcurr, dend))
                        SendAndReset();