Commit 24a38eb3 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by V8 LUCI CQ

Fix IsCBORMessage() to accept correct CBOR envelope

This was originally part of https://crrev.com/c/v8/v8/+/3662540, but
got accidentally lost during revert and re-roll.

Change-Id: I38097884e50f086e2a71319cf820c628ba736a8a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3687417
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80946}
parent 11a1ac4b
...@@ -34,8 +34,10 @@ using v8_crdtp::json::ConvertCBORToJSON; ...@@ -34,8 +34,10 @@ using v8_crdtp::json::ConvertCBORToJSON;
using v8_crdtp::json::ConvertJSONToCBOR; using v8_crdtp::json::ConvertJSONToCBOR;
bool IsCBORMessage(StringView msg) { bool IsCBORMessage(StringView msg) {
return msg.is8Bit() && msg.length() >= 2 && msg.characters8()[0] == 0xd8 && if (!msg.is8Bit() || msg.length() < 3) return false;
msg.characters8()[1] == 0x5a; const uint8_t* bytes = msg.characters8();
return bytes[0] == 0xd8 &&
(bytes[1] == 0x5a || (bytes[1] == 0x18 && bytes[2] == 0x5a));
} }
Status ConvertToCBOR(StringView state, std::vector<uint8_t>* cbor) { Status ConvertToCBOR(StringView state, std::vector<uint8_t>* cbor) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment