Skip to content

Commit

Permalink
r.geomorphon: Fix an out-of-bounds read w/multires (#995)
Browse files Browse the repository at this point in the history
There was a comma missing between array initializers, so the element at
index 3 ended up set to a longer string, and the element at index 4 did
not exist because the array is defined without an explicit size.

This squelches a warning from gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0:

main.c:504:47: warning: iteration 4 invokes undefined behavior
[-Waggressive-loop-optimizations]
  504 |      strcat(multiple_output[i].name, postfixes[i]);
      |                                      ~~~~~~~~~^~~
main.c:501:2: note: within this loop
  501 |  for (i = 0; i < 5; ++i) {
      |  ^~~
  • Loading branch information
infrastation authored and neteler committed Sep 28, 2020
1 parent 5b53982 commit ea75276
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion raster/r.geomorphon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ int main(int argc, char **argv)
if (multires) {
PATTERN *multi_patterns;
MULTI multiple_output[5]; /* ten form maps + all forms */
char *postfixes[] = { "scale_300", "scale_100", "scale_50", "scale_20" "scale_10" }; /* in pixels */
char *postfixes[] = { "scale_300", "scale_100", "scale_50", "scale_20", "scale_10" }; /* in pixels */
num_of_steps = 5;
multi_patterns = G_malloc(num_of_steps * sizeof(PATTERN));
/* prepare outputs */
Expand Down

0 comments on commit ea75276

Please sign in to comment.