pitrou commented on code in PR #49771:
URL: https://github.com/apache/arrow/pull/49771#discussion_r3421700396


##########
cpp/src/arrow/ipc/message.cc:
##########
@@ -563,7 +563,25 @@ Status DecodeMessage(MessageDecoder* decoder, 
io::InputStream* file) {
   }
 
   auto metadata_length = decoder->next_required_size();
+
+  // "ARRO" (first 4 bytes of kArrowMagicBytes) as little-endian int32.
+  constexpr int32_t kArrowMagicPrefix = 0x4F525241;
+
+  // Did we misinterpret the metadata as a length?
+  if (metadata_length == kArrowMagicPrefix) {
+    constexpr std::string_view kRemainingMagic =
+        internal::kArrowMagicBytes.substr(sizeof(int32_t));
+    ARROW_ASSIGN_OR_RAISE(auto peek, file->Read(kRemainingMagic.size()));
+    if (peek->size() >= static_cast<int64_t>(kRemainingMagic.size()) &&
+        std::string_view(reinterpret_cast<const char*>(peek->data()),
+                         kRemainingMagic.size()) == kRemainingMagic) {

Review Comment:
   Letting it fall through means a mythical user with a valid 0x4F525241 bytes 
metadata block will get a regression with a weird message decoding the 
Flatbuffers metadata. I'd rather an explicit message.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to