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

[XrdHttp + XrdHttpExtHandler] Fixes a segmentation fault happening when a client sends a first line starting with a space #1798

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/XrdHttp/XrdHttpExtHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ verb(req->requestverb), headers(req->allheaders) {
int envlen = 0;

headers["xrd-http-query"] = req->opaque?req->opaque->Env(envlen):"";
headers["xrd-http-fullresource"] = req->resourceplusopaque.c_str();
const char * resourcePlusOpaque = req->resourceplusopaque.c_str();
headers["xrd-http-fullresource"] = resourcePlusOpaque != nullptr ? resourcePlusOpaque:"";
headers["xrd-http-prot"] = prot->isHTTPS()?"https":"http";

// These fields usually identify the client that connected
Expand Down
10 changes: 9 additions & 1 deletion src/XrdHttp/XrdHttpReq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,21 @@ int XrdHttpReq::parseFirstLine(char *line, int len) {
return -1;
}

// The first token cannot be too long

pos = p - line;
// The first token cannot be too long
if (pos > MAX_TK_LEN - 1) {
request = rtMalformed;
return -2;
}

// The first space-delimited char cannot be the first one
// this allows to deal with the case when a client sends a first line that starts with a space " GET / HTTP/1.1"
if(pos == 0) {
request = rtMalformed;
return -4;
}

// the first token must be non empty
if (pos > 0) {
line[pos] = 0;
Expand Down