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

BufferOverflow fix + HTTP Header size max #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Source/Core/NptHttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ NPT_HttpHeaders::Parse(NPT_BufferedInputStream& stream)
break;
}
if (header_pending && (line[0] == ' ' || line[0] == '\t')) {
// limit size of multiline header
if (header_value.GetLength() >= NPT_HTTP_PROTOCOL_MAX_LINE_LENGTH) continue;
// continuation (folded header)
header_value.Append(line.GetChars()+1, line.GetLength()-1);
} else {
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/NptStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ NPT_String::Append(const char* str, NPT_Size length)
NPT_Size old_length = GetLength();
NPT_Size new_length = old_length + length;

// avoid Buffer Overflow
if(new_length < old_length) return;

// allocate enough space
Reserve(new_length);

Expand Down