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

d.labels: Fix buffer overflow issues in do_labels.c #4041

Merged
merged 17 commits into from
Jul 26, 2024
Merged
14 changes: 7 additions & 7 deletions display/d.labels/do_labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
else if (!strncmp(text, "yof", 3))
sscanf(text, "%*s %d", &yoffset);
else if (!strncmp(text, "col", 3)) {
sscanf(text, "%*s %s", buff);
sscanf(text, "%*s %127s", buff);
nilason marked this conversation as resolved.
Show resolved Hide resolved
set_RGBA_from_str(&color, buff);
}
else if (!strncmp(text, "siz", 3))
Expand All @@ -94,15 +94,15 @@
else if (!strncmp(text, "wid", 3))
sscanf(text, "%*s %lf", &width);
else if (!strncmp(text, "bac", 3)) {
sscanf(text, "%*s %s", buff);
sscanf(text, "%*s %127s", buff);
set_RGBA_from_str(&background, buff);
}
else if (!strncmp(text, "bor", 3)) {
sscanf(text, "%*s %s", buff);
sscanf(text, "%*s %127s", buff);
set_RGBA_from_str(&border, buff);
}
else if (!strncmp(text, "opa", 3)) {
sscanf(text, "%*s %s", buff);
sscanf(text, "%*s %127s", buff);
if (!strncmp(buff, "YES", 3))
opaque = YES;
else
Expand All @@ -115,15 +115,15 @@
}
}
else if (!strncmp(text, "fon", 3)) {
if (sscanf(text, "%*s %s", font) != 1 || !strcmp(font, "standard"))
if (sscanf(text, "%*s %255s", font) != 1 || !strcmp(font, "standard"))
strcpy(font, std_font);
}
else if (!strncmp(text, "rot", 3)) {
if (do_rotation)
sscanf(text, "%*s %lf", &rotation);
}
else if (!strncmp(text, "hco", 3)) {
sscanf(text, "%*s %s", buff);
sscanf(text, "%*s %127s", buff);
set_RGBA_from_str(&highlight_color, buff);
}
else if (!strncmp(text, "hwi", 3))
Expand Down Expand Up @@ -452,7 +452,7 @@
if (buf[i] >= 'A' && buf[i] <= 'Z')
buf[i] += 'a' - 'A';
xref = yref = CENT;
switch (sscanf(buf, "%s%s", word1, word2)) {
switch (sscanf(buf, "%49s%49s", word1, word2)) {
ShubhamDesai marked this conversation as resolved.
Show resolved Hide resolved
case 2:
if (!(xmatch(word2) || ymatch(word2)))
return 0;
Expand Down
Loading