diff --git a/tools/fuzzing/ipc/IPCFuzzController.cpp b/tools/fuzzing/ipc/IPCFuzzController.cpp index 3ec51280500e..e3e7c30654da 100644 --- a/tools/fuzzing/ipc/IPCFuzzController.cpp +++ b/tools/fuzzing/ipc/IPCFuzzController.cpp @@ -587,7 +587,12 @@ bool IPCFuzzController::MakeTargetDecision( } else if (isPreserveHeader) { // In preserveHeaderMode, we need to find an actor that matches the // requested message type instead of any random actor. - ProtocolId wantedProtocolId = static_cast(*type >> 16); + uint16_t maybeProtocolId = *type >> 16; + if (maybeProtocolId >= IPCMessageStart::LastMsgIndex) { + // Not a valid protocol. + return false; + } + ProtocolId wantedProtocolId = static_cast(maybeProtocolId); std::vector allowedIndices; for (uint32_t i = 0; i < actors.size(); ++i) { if (actors[i].second == wantedProtocolId) {