From e6ce3746cdcf0836b9dae659a5aed15d73a080d8 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Fri, 10 Jun 2022 00:28:29 +0530 Subject: [PATCH] libnsgif: fix oob in lzw_decode --- libnsgif/lzw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libnsgif/lzw.c b/libnsgif/lzw.c index 2282898e..152892e3 100644 --- a/libnsgif/lzw.c +++ b/libnsgif/lzw.c @@ -329,6 +329,10 @@ lzw_result lzw_decode(struct lzw_ctx *ctx, /* Code is invalid */ return LZW_BAD_CODE; + } else if (code_new >= 1 << LZW_CODE_MAX) { + /* Don't access out of bound */ + return LZW_BAD_CODE; + } else if (code_new < current_entry) { /* Code is in table */ code_out = code_new;