| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media/cast_remoting_connector_messaging.h" | 5 #include "chrome/browser/media/cast_remoting_connector_messaging.h" |
| 6 | 6 |
| 7 // Entry point for LibFuzzer. | 7 // Entry point for LibFuzzer. |
| 8 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 8 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 9 // All of the input is used as the text message. | 9 // All of the input is used as the text message. |
| 10 const std::string text_message(reinterpret_cast<const char*>(data), size); | 10 const std::string text_message(reinterpret_cast<const char*>(data), size); |
| 11 | 11 |
| 12 // Compute an arbitrary, but deterministic "expected session ID." | 12 // Compute an arbitrary, but deterministic "expected session ID." |
| 13 const unsigned int session_id = size / 4; | 13 const unsigned int session_id = size / 4; |
| 14 | 14 |
| 15 // Make sure the compiler does not try to optimize-away calls by storing their | 15 // Make sure the compiler does not try to optimize-away calls by storing their |
| 16 // results in a volatile variable. | 16 // results in a volatile variable. |
| 17 volatile unsigned int ignored_result; | 17 volatile unsigned int ignored_result; |
| 18 (void)ignored_result; |
| 18 | 19 |
| 19 using Messaging = CastRemotingConnectorMessaging; | 20 using Messaging = CastRemotingConnectorMessaging; |
| 20 | 21 |
| 21 if (Messaging::IsMessageForSession( | 22 if (Messaging::IsMessageForSession( |
| 22 text_message, Messaging::kStartedStreamsMessageFormatPartial, | 23 text_message, Messaging::kStartedStreamsMessageFormatPartial, |
| 23 session_id)) { | 24 session_id)) { |
| 24 ignored_result = Messaging::GetStreamIdFromStartedMessage( | 25 ignored_result = Messaging::GetStreamIdFromStartedMessage( |
| 25 text_message, Messaging::kStartedStreamsMessageAudioIdSpecifier); | 26 text_message, Messaging::kStartedStreamsMessageAudioIdSpecifier); |
| 26 ignored_result = Messaging::GetStreamIdFromStartedMessage( | 27 ignored_result = Messaging::GetStreamIdFromStartedMessage( |
| 27 text_message, Messaging::kStartedStreamsMessageVideoIdSpecifier); | 28 text_message, Messaging::kStartedStreamsMessageVideoIdSpecifier); |
| 28 } | 29 } |
| 29 ignored_result = Messaging::IsMessageForSession( | 30 ignored_result = Messaging::IsMessageForSession( |
| 30 text_message, Messaging::kFailedMessageFormat, session_id); | 31 text_message, Messaging::kFailedMessageFormat, session_id); |
| 31 ignored_result = Messaging::IsMessageForSession( | 32 ignored_result = Messaging::IsMessageForSession( |
| 32 text_message, Messaging::kStoppedMessageFormat, session_id); | 33 text_message, Messaging::kStoppedMessageFormat, session_id); |
| 33 | 34 |
| 34 return 0; | 35 return 0; |
| 35 } | 36 } |
| OLD | NEW |