Skip to content

Commit

Permalink
[Fix] Do not set HTTP_RAW_POST_DATA if it cause String overflow
Browse files Browse the repository at this point in the history
Summary:
In video upload, the amount of data can overflow a String and cause exception
to be throw. I made a change so that we don't store HTTP_RAW_POST_DATA when
this happens.

Test Plan:
make fast_tests
upload a large video in non-chunk mode and make sure no exception is thrown
at the end.

Reviewers: mwilliams, qigao

Reviewed By: mwilliams

CC: hphp-diffs@lists, ps, mwilliams

Differential Revision: 345263
  • Loading branch information
myang authored and macvicar committed Oct 18, 2011
1 parent 2609d94 commit d89445d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/base/server/http_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,17 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
}
CopyParams(request, g->GV(_POST));
if (needDelete) {
if (RuntimeOption::AlwaysPopulateRawPostData) {
if (RuntimeOption::AlwaysPopulateRawPostData &&
size <= (int)StringData::LenMask) {
g->GV(HTTP_RAW_POST_DATA) = String((char*)data, size, AttachString);
} else {
free((void *)data);
}
} else {
// For literal we disregard RuntimeOption::AlwaysPopulateRawPostData
g->GV(HTTP_RAW_POST_DATA) = String((char*)data, size, AttachLiteral);
if (size <= (int)StringData::LenMask) {
g->GV(HTTP_RAW_POST_DATA) = String((char*)data, size, AttachLiteral);
}
}
}
}
Expand Down

0 comments on commit d89445d

Please sign in to comment.