Permalink
Browse files

Fix an off-by-one bug in addStatusHeaderFromStatusLine().

  • Loading branch information...
1 parent f99ad28 commit 9f5da461e513830c30344628ce89e4e6512c0736 @FooBarWidget FooBarWidget committed Apr 2, 2013
Showing with 9 additions and 3 deletions.
  1. +9 −3 ext/common/agents/HelperAgent/RequestHandler.h
@@ -853,10 +853,16 @@ class RequestHandler {
}
bool addStatusHeaderFromStatusLine(const ClientPtr &client, string &headerData) {
- string::size_type begin = headerData.find(' ');
- string::size_type end = headerData.find("\r\n");
+ string::size_type begin, end;
+
+ begin = headerData.find(' ');
+ if (begin != string::npos) {
+ end = headerData.find("\r\n", begin + 1);
+ } else {
+ end = string::npos;
+ }
if (begin != string::npos && end != string::npos) {
- StaticString statusValue(headerData.data() + begin, end - begin);
+ StaticString statusValue(headerData.data() + begin + 1, end - begin);
char header[statusValue.size() + 20];
char *pos = header;
const char *end = header + statusValue.size() + 20;

0 comments on commit 9f5da46

Please sign in to comment.