-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix: prevent buffer overflow #74
Conversation
Closes #73 Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
The test
|
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
Why not just use a dynamically allocated string here? Currently it silently truncates and
Would end up parsed as |
It would make sense to already implement that proposed change, indeed. editorconfig/editorconfig-core-test#41 However, the goal here is to avoid the buffer overflow. |
Actually, looking at the code the allocation can actually be avoided at that point - just use |
@@ -138,7 +138,7 @@ static int array_editorconfig_name_value_add( | |||
int name_value_pos; | |||
/* always use name_lwr but not name, since property names are case | |||
* insensitive */ | |||
char name_lwr[MAX_PROPERTY_NAME]; | |||
char name_lwr[MAX_PROPERTY_NAME+1] = {0}; |
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.
This is a point that I missed in the original implementation. Thanks!
There is probably a better way though.
Closes #73