summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/pcx.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 77b2331f0e..2191ad1503 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -28,6 +28,8 @@
#include "get_bits.h"
#include "internal.h"
+#define PCX_HEADER_SIZE 128
+
/**
* @return advanced src pointer
*/
@@ -85,6 +87,11 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
uint8_t *scanline;
int ret = -1;
+ if (buf_size < PCX_HEADER_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "Packet too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;