Repository navigation
raster: Fix three single-alert CodeQL findings - #7702
Merged
Merged
Conversation
r.watershed (ram): checking sscanf against 0 misses the EOF return, so use != 1 as the seg variant already does. r.viewshed: bound the inner column loop by the local int ncols cast to dimensionType, matching the row loop, instead of comparing the unsigned short counter directly to Rast_window_cols(). r.in.gdal: drop the null check on sdsdesc, which is always assigned a non-null pointer beforehand.
petrasovaa
approved these changes
Jul 14, 2026
echoix
reviewed
Jul 14, 2026
echoix
reviewed
Jul 14, 2026
echoix
left a comment
Member
There was a problem hiding this comment.
I can’t comment on the two other files, but for the sscanf, it is the correct fix, and the only one I actually dug in a bit this week.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three single-alert CodeQL code scanning findings, one per tool:
ram/init_vars.c,cpp/incorrectly-checked-scanf, error severity):sscanf(ril_name, "%lf", &ril_value) == 0misses the EOF (-1) return. Changed to!= 1, which is also exactly what the seg variant (seg/init_vars.c) already does on the same line.grass.cpp,cpp/comparison-with-wider-type): the inner column loop counterjisdimensionType(unsigned short) but was compared againstint Rast_window_cols(). Now bounded by the existing localncolscast todimensionType, matching the row loop one line above. The comparison is safe in practice because of themaxDimensionguard, but the loop now mirrors the row loop and avoids the repeated function call.main.c,cpp/redundant-null-check-simple, error severity):sdsdescis unconditionally assigned a non-null pointer before theif (sdsdesc && *sdsdesc)check, so the null test is dead code; dropped it.All three tools compile and their testsuites pass locally against nc_spm (r.watershed, r.viewshed, and r.in.gdal's 12 tests).
This is part of a larger effort to work through the open code scanning alerts, grouped into small PRs by issue type.
Written with the assistance of Claude Code.