Skip to content

Commit

Permalink
[XrdHttp + XrdHttpExtHandler] Fixes a segmentation fault happening wh…
Browse files Browse the repository at this point in the history
…en a client sends a first line starting with a space
  • Loading branch information
ccaffy committed Oct 10, 2022
1 parent fdfe7ef commit e0501bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/XrdHttp/XrdHttpExtHandler.cc
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
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

0 comments on commit e0501bb

Please sign in to comment.