Skip to content
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

Fixed handling of long strings when using INI_USE_STACK #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,

lineno++;

#if INI_USE_STACK
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do this check whether or not INI_USE_STACK is set, right? Because even in non-stack mode we might have read and realloc'd up to INI_MAX_LINE bytes.

if (strlen(line) == max_line - 1 && line[max_line - 2] != '\n') {
/* Exit even if INI_STOP_ON_FIRST_ERROR is not set */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure about this. If INI_STOP_ON_FIRST_ERROR is false (the default), I think we should read and discard the rest of the current line, and then proceed. We could decide to do this as a stop-gap fix, but I'm not sure that's a good idea -- if we fix this I think we should do it properly in a single PR.

You can see how it's breaking the existing max-line tests as it is currently.

error = lineno;
break;
}
#endif

start = line;
#if INI_ALLOW_BOM
if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
Expand Down