Skip to content

d.vect: Fix Copy into fixed buffer size issues #6138

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion display/d.vect/legend.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/vector.h>
#include "local_proto.h"

Expand All @@ -13,7 +14,9 @@ void write_into_legfile(struct Map_info *Map, int type, const char *leglab,
char *leg_file;
char map[GNAME_MAX];
char *ptr;
strcpy(map, name_map);
if (G_strlcpy(map, name_map, sizeof(map)) >= sizeof(map)) {
G_fatal_error(_("Map name <%s> is too long"), name_map);
}
#ifdef _MSC_VER
strtok_s(map, "@", &ptr);
#else
Expand Down
4 changes: 3 additions & 1 deletion display/d.vect/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ int main(int argc, char **argv)
}
}

strcpy(map_name, map_opt->answer);
if (G_strlcpy(map_name, map_opt->answer, sizeof(map_name)) >= sizeof(map_name)) {
G_fatal_error(_("Map name <%s> is too long"), map_opt->answer);
}

default_width = atoi(width_opt->answer);
if (default_width < 0)
Expand Down
Loading