Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Potential Vulnerability in Cloned Function #4690

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions examples/ThirdPartyLibs/zlib/inftrees.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unsigned short FAR *work;
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
int end; /* use base and extra for symbol > end */
unsigned match; /* use base and extra for symbol >= match */
unsigned short count[MAXBITS + 1]; /* number of codes of each length */
unsigned short offs[MAXBITS + 1]; /* offsets in table for each length */
static const unsigned short lbase[31] = {/* Length codes 257..285 base */
Expand Down Expand Up @@ -184,19 +184,17 @@ unsigned short FAR *work;
{
case CODES:
base = extra = work; /* dummy value--not used */
end = 19;
match = 20;
break;
case LENS:
base = lbase;
base -= 257;
extra = lext;
extra -= 257;
end = 256;
match = 257;
break;
default: /* DISTS */
base = dbase;
extra = dext;
end = -1;
match = 0;
}

/* initialize state for loop */
Expand All @@ -220,15 +218,15 @@ unsigned short FAR *work;
{
/* create table entry */
here.bits = (unsigned char)(len - drop);
if ((int)(work[sym]) < end)
if (work[sym] + 1 < match) {
{
here.op = (unsigned char)0;
here.val = work[sym];
}
else if ((int)(work[sym]) > end)
else if (work[sym] >= match)
{
here.op = (unsigned char)(extra[work[sym]]);
here.val = base[work[sym]];
here.op = (unsigned char)(extra[work[sym] - match]);
here.val = base[work[sym] - match];
}
else
{
Expand Down