diff options
author | James Zern <jzern@google.com> | 2019-03-08 20:42:26 -0800 |
---|---|---|
committer | James Zern <jzern@google.com> | 2019-03-08 20:45:59 -0800 |
commit | bc32e3c6b0aff6fb32a413203352ec4632b1424f (patch) | |
tree | 451f9790c7d65e60e6b9a38f09d1de71cbb03866 /m2ts | |
parent | 2427abe0bde234987ed005a3adca461e9a85dfb7 (diff) | |
download | libwebm-bc32e3c6b0aff6fb32a413203352ec4632b1424f.tar.gz |
webm2pes: avoid null deref w/track->GetCodecId()
check pointer value before converting to string
fixes CVE-2018-19212
BUG=webm:1605
Change-Id: Idbe51dc8e0e454019003ba1ac7afa175f7bf8950
Diffstat (limited to 'm2ts')
-rw-r--r-- | m2ts/webm2pes.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/m2ts/webm2pes.cc b/m2ts/webm2pes.cc index f510acf..fc4b314 100644 --- a/m2ts/webm2pes.cc +++ b/m2ts/webm2pes.cc @@ -20,6 +20,14 @@ namespace libwebm { const std::size_t Webm2Pes::kMaxPayloadSize = 32768; +namespace { + +std::string ToString(const char* str) { + return std::string((str == nullptr) ? "" : str); +} + +} // namespace + // // PesOptionalHeader methods. // @@ -382,9 +390,10 @@ bool Webm2Pes::InitWebmParser() { ++track_index) { const mkvparser::Track* track = tracks->GetTrackByIndex(track_index); if (track && track->GetType() == mkvparser::Track::kVideo) { - if (std::string(track->GetCodecId()) == std::string("V_VP8")) { + const std::string codec_id = ToString(track->GetCodecId()); + if (codec_id == std::string("V_VP8")) { codec_ = VideoFrame::kVP8; - } else if (std::string(track->GetCodecId()) == std::string("V_VP9")) { + } else if (codec_id == std::string("V_VP9")) { codec_ = VideoFrame::kVP9; } else { fprintf(stderr, "Webm2Pes: Codec must be VP8 or VP9.\n"); |