$NetBSD: patch-decode.c,v 1.2 2022/01/08 14:43:09 tnn Exp $ Fix CVE-2015-2782. Via Debian security-afl.patch. Fix out-of-bounds read via Debian out-of-bounds-read.patch. --- decode.c.orig 2022-01-08 14:27:21.037706349 +0000 +++ decode.c @@ -255,7 +255,7 @@ void read_pt_len(int nn, int nbit, int i if(i==i_special) { c=getbits(2); - while(--c>=0) + while(--c>=0&&i=0) + while(--c>=0&&i=ARJSFXV if(!setjmp(decode_proc)) @@ -450,9 +450,12 @@ void decode(int action) { j=c-(UCHAR_MAX+1-THRESHOLD); count-=(unsigned long)j; - i=r-decode_p()-1; + int P = decode_p(); + i=r-P-1; if(i<0) i+=DICSIZ; + if(i<0) + goto termination; if(r>i&&r=0)