From 5c5be8ba69a49c5fe7510bbb9f11f8a4ecf4a4fb Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 2 May 2012 12:38:10 -0700 Subject: [PATCH] VP8[L]GetInfo: check input pointers validate data before using & width/height before assigning. Change-Id: I0872e80fcbfea295d7c633b0d4cb7809e1d1883b --- src/dec/vp8.c | 2 +- src/dec/vp8l.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dec/vp8.c b/src/dec/vp8.c index ff3c7d1f..c73585df 100644 --- a/src/dec/vp8.c +++ b/src/dec/vp8.c @@ -84,7 +84,7 @@ int VP8SetError(VP8Decoder* const dec, int VP8GetInfo(const uint8_t* data, size_t data_size, size_t chunk_size, int* width, int* height) { - if (data_size < 10) { + if (data == NULL || data_size < VP8_FRAME_HEADER_SIZE) { return 0; // not enough data } // check signature diff --git a/src/dec/vp8l.c b/src/dec/vp8l.c index e6742eaa..92e62d22 100644 --- a/src/dec/vp8l.c +++ b/src/dec/vp8l.c @@ -96,7 +96,7 @@ static int ReadImageSize(VP8LBitReader* const br, int VP8LGetInfo(const uint8_t* data, size_t data_size, int* width, int* height) { - if (data_size < kHeaderBytes) { + if (data == NULL || data_size < kHeaderBytes) { return 0; // not enough data } else { int w, h; @@ -105,8 +105,8 @@ int VP8LGetInfo(const uint8_t* data, size_t data_size, if (!ReadImageSize(&br, &w, &h)) { return 0; } - *width = w; - *height = h; + if (width != NULL) *width = w; + if (height != NULL) *height = h; return 1; } }