Skip to content

Commit

Permalink
r.clump: Fix Copy Buffer Size Issue (OSGeo#4816)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamDesai authored Dec 9, 2024
1 parent 70fe643 commit 4402747
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 4402747

Please sign in to comment.