Add a few bounds checks
This commit is contained in:
parent
a614fe615f
commit
aaf593d2df
@ -483,13 +483,13 @@ parse_sgr(Screen *screen, uint32_t *buf, unsigned int num, unsigned int *params,
|
|||||||
}
|
}
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case START:
|
case START:
|
||||||
params[num_params++] = 0;
|
if (num_params < MAX_PARAMS) params[num_params++] = 0;
|
||||||
SEND_SGR;
|
SEND_SGR;
|
||||||
break;
|
break;
|
||||||
case COLOR1:
|
case COLOR1:
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
case MULTIPLE:
|
case MULTIPLE:
|
||||||
if (i > num_start) { READ_PARAM; }
|
if (i > num_start && num_params < MAX_PARAMS) { READ_PARAM; }
|
||||||
if (num_params) { SEND_SGR; }
|
if (num_params) { SEND_SGR; }
|
||||||
else { REPORT_ERROR("Incomplete SGR code"); }
|
else { REPORT_ERROR("Incomplete SGR code"); }
|
||||||
break;
|
break;
|
||||||
@ -497,7 +497,7 @@ parse_sgr(Screen *screen, uint32_t *buf, unsigned int num, unsigned int *params,
|
|||||||
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
||||||
break;
|
break;
|
||||||
case COLOR3:
|
case COLOR3:
|
||||||
if (i > num_start) READ_PARAM;
|
if (i > num_start && num_params < MAX_PARAMS) READ_PARAM;
|
||||||
if (num_params != 5) {
|
if (num_params != 5) {
|
||||||
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user