Skip to content

Commit

Permalink
Fixed a memory overrun when gradient_count > 8
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremiasStotter authored and karlstav committed Dec 30, 2023
1 parent 2498a5c commit 4cbd13d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ bool validate_colors(void *params, void *err) {
}

if (p->gradient) {
if (p->gradient_count < 2) {
write_errorf(error, "\nAtleast two colors must be given as gradient!\n");
return false;
}
if (p->gradient_count > 8) {
write_errorf(error, "\nMaximum 8 colors can be specified as gradient!\n");
return false;
}

for (int i = 0; i < p->gradient_count; i++) {
if (!validate_color(p->gradient_colors[i], p, error)) {
write_errorf(
Expand Down Expand Up @@ -182,17 +191,6 @@ bool validate_colors(void *params, void *err) {
if (p->bcolor[0] == '#')
p->bgcol = 8;
// default if invalid
if (p->gradient) {

if (p->gradient_count < 2) {
write_errorf(error, "\nAtleast two colors must be given as gradient!\n");
return false;
}
if (p->gradient_count > 8) {
write_errorf(error, "\nMaximum 8 colors can be specified as gradient!\n");
return false;
}
}

return true;
}
Expand Down

0 comments on commit 4cbd13d

Please sign in to comment.