# HG changeset patch # User michael # Date 1113990724 0 # Node ID c39756a516a5ce4f21f890f7810b8c6988b0700f # Parent fc91ca5b90666612e7b3a4af86a49b7d3eb54ef2 buffer overflows diff -r fc91ca5b9066 -r c39756a516a5 indeo2.c --- a/indeo2.c Wed Apr 20 09:42:47 2005 +0000 +++ b/indeo2.c Wed Apr 20 09:52:04 2005 +0000 @@ -53,7 +53,7 @@ else if (value < 0) \ value = 0; \ -static void ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, +static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, const uint8_t *table) { int i; @@ -62,11 +62,16 @@ int c; int t; + if(width&1) + return -1; + /* first line contain absolute values, other lines contain deltas */ while (out < width){ c = ir2_get_code(&ctx->gb); if(c > 0x80) { /* we have a run */ c -= 0x80; + if(out + c*2 > width) + return -1; for (i = 0; i < c * 2; i++) dst[out++] = 0x80; } else { /* copy two values from table */ @@ -82,6 +87,8 @@ c = ir2_get_code(&ctx->gb); if(c > 0x80) { /* we have a skip */ c -= 0x80; + if(out + c*2 > width) + return -1; for (i = 0; i < c * 2; i++) { dst[out] = dst[out - stride]; out++; @@ -99,16 +106,20 @@ } dst += stride; } + return 0; } -static void ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, +static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, const uint8_t *table) { int j; int out = 0; int c; int t; - + + if(width&1) + return -1; + for (j = 0; j < height; j++){ out = 0; while (out < width){ @@ -129,6 +140,7 @@ } dst += stride; } + return 0; } static int ir2_decode_frame(AVCodecContext *avctx,