-
Notifications
You must be signed in to change notification settings - Fork 710
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
Bug fix for registry path length checks when doing out-of-source code generation #2136
base: develop
Are you sure you want to change the base?
Conversation
The regression test results:
|
tools/reg_parse.c
Outdated
p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; | ||
if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; } | ||
fprintf( stderr, "Len : %d\n", strlen( p ) ); |
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.
Was this print statement added for debugging purposes? If so, perhaps it could be removed.
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 the catch!
tools/reg_parse.c
Outdated
p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ; | ||
if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; } | ||
fprintf( stderr, "Len : %d\n", strlen( p ) ); | ||
if ( strlen( p ) > MAX_PATH - 1 ) { fprintf(stderr,"Registry error: include file name too long: %s\n", p ) ; } |
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.
For consistency with other messages throughout the registry tool, should we retain the "Registry warning:" text for now rather than "Registry error:"? A separate PR could be used to consistently change "warning" messages to "error" messages throughout the reg_parse.c
code, and at that time, we could also decide whether to use the word "Error" (with a capital-e), as it seems like a lot of guidance to WRF users is to search for "Error" in the build log.
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.
I understand the sentiment, though I think there is something to be said for piecemeal improvements that don't significantly impact functionality while incomplete. I think this could fall under a reasonable clean-as-you-go improvement to better the message output to reflect the severity.
There isn't exactly a good precedent set by registry message prefixes both in style and actual severity. Given the lack of consistency in registry messages, I think it would be better to update messages to say what they actually mean whilst editing the relevant code rather than keeping consistent with the most used prefix to be fixed later.
The fix to update message prefixes should still happen, but I don't think that fix should preclude us from making incremental progress.
@mgduda The failure mode was still implicit, so I've added return statements that end Registry processing when these errors are hit. This falls inline with the expected return of this function and the call chain handles it appropriately. |
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.
I will approve this even though it is outside my scope. Is this just related to cmake? If so, the description should reflect that.
TYPE: bug fix
KEYWORDS: registry, path
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem:
PR #1975 added the ability for registry code to be generated out-of-source. To do this, a provided path is used and prepended to include statements within registry files. The max path length checks to create the search path string in a
char*
does not take into account the combined prepend path + relative file path length. When this happens, no obvious errors occur, but a buffer overflow causes malformed registry code to be used, eventually leading to failed compilation.Solution:
Use a max path length that checks both the relative file path length and combined length when using the prepended path. As failure to pass this will result in erroneous code, the error messages have been updated to convey that as well.
TESTS CONDUCTED:
RELEASE NOTE: Bug fix for registry path length checks when doing out-of-source code generation