Skip to content

Commit

Permalink
refactor: add limits for fscanf to avoid crashing for large string in…
Browse files Browse the repository at this point in the history
…puts
  • Loading branch information
Sharansrj567 committed Jan 12, 2024
1 parent 36dbcb6 commit 24c887f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/imagery/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int I_get_group(char *group)
G_suppress_warnings(0);
if (fd == NULL)
return 0;
stat = (fscanf(fd, "%s", group) == 1);
stat = (fscanf(fd, "%255s", group) == 1);
fclose(fd);
return stat;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ int I_get_subgroup(const char *group, char *subgroup)
G_suppress_warnings(0);
if (fd == NULL)
return 0;
stat = (fscanf(fd, "%s", subgroup) == 1);
stat = (fscanf(fd, "%255s", subgroup) == 1);
fclose(fd);
return stat;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ int I_get_subgroup_ref2(const char *group, const char *subgroup,
static int get_ref(const char *group, const char *subgroup, const char *gmapset,
struct Ref *ref)
{
int n;
int n;
char buf[1024];
char name[INAME_LEN], mapset[INAME_LEN];
char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
Expand Down

0 comments on commit 24c887f

Please sign in to comment.