Skip to content

Commit

Permalink
Fix Copy Buffer Size Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham Vasudeo Desai committed Dec 7, 2024
1 parent 2ae6362 commit 44bc123
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions raster/r.clump/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ int main(int argc, char *argv[])
}

INPUT = opt_in->answers[0];
strcpy(name, INPUT);
if (G_strlcpy(name, INPUT, sizeof(name)) >= sizeof(name)) {
G_fatal_error(_("Input raster name <%s> is too long"), INPUT);
}

OUTPUT = NULL;
out_fd = -1;
Expand All @@ -155,8 +157,12 @@ int main(int argc, char *argv[])
G_debug(1, "Creating support files...");

/* build title */
if (opt_title->answer != NULL)
strcpy(title, opt_title->answer);
if (opt_title->answer != NULL) {
if (G_strlcpy(title, opt_title->answer, sizeof(title)) >=
sizeof(title)) {
G_fatal_error(_("Title <%s> is too long"), opt_title->answer);
}
}
else
sprintf(title, "clump of <%s@%s>", name, G_mapset());
Rast_put_cell_title(OUTPUT, title);
Expand Down

0 comments on commit 44bc123

Please sign in to comment.