-
-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
g.region/r.to.rast3elev: fixed scanf error to recognize EOF as a possible return value #3452
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. Most (all?) of these checks are for G_parser()
options. G_parser()
does all necessary sanity checks and returns non-NULL values only if there are any valid values. Even an empty string with an option name (e.g., map=""
) returns a NULL in answer
, so EOF
from sscanf()
is not really a concern when we already check for the nullity of answer
.
sscanf()
returns EOF
if its first argument is an empty string ("\0"
), but G_parser()
doesn't return one in answer
. answer
will be either NULL
or a non-empty string.
Lines 1180 to 1182 in 87d2d42
/* an empty string is not a valid answer, skip */ | |
if (!*string) | |
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this PR, I removed the explicit EOF checks but kept the checks for a scanf return value, since this is generally good practice and one less thing to worry about if ever refactoring.
@HuidaeCho with this PR now limited to only three changes with checks like |
Not only does the parser either return Line 1399 in 8a3c6b7
There is no way a compiler/static analyser could know this. I see two possible "solutions" to this:
|
scanf can return EOF as a return value, which can be a security issue if not accounted for.