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.mon: Fix Unbounded Source Buffer in main.c file of d.mon module #4260

Merged
merged 12 commits into from
Sep 19, 2024
10 changes: 8 additions & 2 deletions display/d.mon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "proto.h"

#define MONITOR_NAME_LIMIT 256

int main(int argc, char *argv[])
{
struct GModule *module;
Expand Down Expand Up @@ -176,7 +178,7 @@ int main(int argc, char *argv[])
if (list_flag->answer)
G_warning(_("Flag -%c ignored"), list_flag->key);
mon = G_getenv_nofatal("MONITOR");
if (mon) {
if (mon && strlen(mon) < MONITOR_NAME_LIMIT) {
nilason marked this conversation as resolved.
Show resolved Hide resolved
if (selected_flag->answer) {
G_verbose_message(_("Currently selected monitor:"));
fprintf(stdout, "%s\n", mon);
Expand All @@ -194,8 +196,12 @@ int main(int argc, char *argv[])
ret = stop_mon(mon);
}
}
else
else if (!mon) {
G_important_message(_("No monitor selected"));
}
else {
G_important_message(_("Monitor name is too long"));
}

exit(EXIT_SUCCESS);
}
Expand Down
Loading