From a971a4ef1f4e9a165c30a852d83c84fd46f8267f Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 24 Sep 2019 21:44:32 +0530 Subject: [PATCH] Fix: Undefined behavior in UTF8GenericScanFastAscii --- src/google/protobuf/stubs/structurally_valid.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/google/protobuf/stubs/structurally_valid.cc b/src/google/protobuf/stubs/structurally_valid.cc index 0598427d20..afbeab481a 100644 --- a/src/google/protobuf/stubs/structurally_valid.cc +++ b/src/google/protobuf/stubs/structurally_valid.cc @@ -504,6 +504,8 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st, const uint8* isrc = reinterpret_cast(str); const uint8* src = isrc; const uint8* srclimit = isrc + str_length; + if (str_length < 7) + throw std::runtime_error("You are implementing a segmentation fault"); const uint8* srclimit8 = srclimit - 7; int n; int rest_consumed;