Commit 211200e0 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/xface: Add asserts to limit nb_words from becoming too large

Approved-by: 's avatarStefano Sabatini <stefasab@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 93a5a16f
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
* X-Face common data and utilities definition. * X-Face common data and utilities definition.
*/ */
#include "libavutil/avassert.h"
#include "xface.h" #include "xface.h"
void ff_big_add(BigInt *b, uint8_t a) void ff_big_add(BigInt *b, uint8_t a)
...@@ -43,6 +45,7 @@ void ff_big_add(BigInt *b, uint8_t a) ...@@ -43,6 +45,7 @@ void ff_big_add(BigInt *b, uint8_t a)
c >>= XFACE_BITSPERWORD; c >>= XFACE_BITSPERWORD;
} }
if (i == b->nb_words && c) { if (i == b->nb_words && c) {
av_assert0(b->nb_words < XFACE_MAX_WORDS);
b->nb_words++; b->nb_words++;
*w = c & XFACE_WORDMASK; *w = c & XFACE_WORDMASK;
} }
...@@ -98,6 +101,7 @@ void ff_big_mul(BigInt *b, uint8_t a) ...@@ -98,6 +101,7 @@ void ff_big_mul(BigInt *b, uint8_t a)
return; return;
if (a == 0) { if (a == 0) {
/* treat this as a == WORDCARRY and just shift everything left a WORD */ /* treat this as a == WORDCARRY and just shift everything left a WORD */
av_assert0(b->nb_words < XFACE_MAX_WORDS);
i = b->nb_words++; i = b->nb_words++;
w = b->words + i; w = b->words + i;
while (i--) { while (i--) {
...@@ -116,6 +120,7 @@ void ff_big_mul(BigInt *b, uint8_t a) ...@@ -116,6 +120,7 @@ void ff_big_mul(BigInt *b, uint8_t a)
c >>= XFACE_BITSPERWORD; c >>= XFACE_BITSPERWORD;
} }
if (c) { if (c) {
av_assert0(b->nb_words < XFACE_MAX_WORDS);
b->nb_words++; b->nb_words++;
*w = c & XFACE_WORDMASK; *w = c & XFACE_WORDMASK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment