Skip to content

Comments

r.fill.dir: avoid null pointer dereferences#5422

Merged
echoix merged 1 commit intoOSGeo:mainfrom
nilason:fix_r_fill_dir
Apr 5, 2025
Merged

r.fill.dir: avoid null pointer dereferences#5422
echoix merged 1 commit intoOSGeo:mainfrom
nilason:fix_r_fill_dir

Conversation

@nilason
Copy link
Contributor

@nilason nilason commented Mar 21, 2025

This most likely addresses a false positive static analyser issue, which was raised after merge of 9fdce5a.

But it doesn't hurt to add this simple check either.

*** CID 1593959:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 165 in ppupdate()
159     
160             n = list[i].next;
161             if (list[n].next == i) {
162                 /* we have a pair */
163                 /* find out how large the elevation difference would be for a change
164                  * in each basin */
   CID 1593959:  Null pointer dereferences  (FORWARD_NULL)
   Passing null pointer "that_elev" to "memcpy", which dereferences it.
165                 memcpy(that_elev, list[n].pp_alt, bpe());
166                 diff(that_elev, list[n].pp);
167     
168                 memcpy(this_elev, list[i].pp_alt, bpe());
169                 diff(this_elev, list[i].pp);
170     

** CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 168 in ppupdate()


________________________________________________________________________________________________________
*** CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 168 in ppupdate()
162                 /* we have a pair */
163                 /* find out how large the elevation difference would be for a change
164                  * in each basin */
165                 memcpy(that_elev, list[n].pp_alt, bpe());
166                 diff(that_elev, list[n].pp);
167     
   CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
   Passing null pointer "this_elev" to "memcpy", which dereferences it.
168                 memcpy(this_elev, list[i].pp_alt, bpe());
169                 diff(this_elev, list[i].pp);
170     
171                 /* switch pour points in the basin where it makes the smallest
172                  * change */
173                 if (get_min(this_elev, that_elev) == this_elev) {

@nilason nilason added this to the 8.5.0 milestone Mar 21, 2025
@github-project-automation github-project-automation bot moved this to In Progress in GRASS Security Mar 21, 2025
@github-actions github-actions bot added raster Related to raster data processing C Related code is in C module labels Mar 21, 2025
@echoix echoix merged commit d427d0b into OSGeo:main Apr 5, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in GRASS Security Apr 5, 2025
@nilason nilason deleted the fix_r_fill_dir branch April 27, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C module raster Related to raster data processing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants