From ff6ae867f89e5c0a0a0da498f17ea964e2125b87 Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Tue, 12 Jul 2016 10:38:14 +0200 Subject: [PATCH] Don't trim printable characters Fix SEGV when passing a destination header line containing only non-alphanumeric characters --- src/XrdHttp/XrdHttpReq.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/XrdHttp/XrdHttpReq.cc b/src/XrdHttp/XrdHttpReq.cc index fb12e792276..c96c18eefbe 100644 --- a/src/XrdHttp/XrdHttpReq.cc +++ b/src/XrdHttp/XrdHttpReq.cc @@ -88,11 +88,11 @@ void trim(std::string &str) { // Trim leading non-letters - while(str.size() && !isalnum(str[0])) str.erase(str.begin()); + while( str.size() && !isgraph(str[0]) ) str.erase(str.begin()); // Trim trailing non-letters - while(str.size() && !isalnum(str[str.size()-1])) + while( str.size() && !isgraph(str[str.size()-1]) ) str.resize (str.size () - 1); } @@ -160,7 +160,7 @@ int XrdHttpReq::parseLine(char *line, int len) { char *val = line + pos + 1; // Trim left - while (!isalnum(*val) || (!*val)) val++; + while ( (!isgraph(*val) || (!*val)) && (val < line+len)) val++; // Here we are supposed to initialize whatever flag or variable that is needed // by looking at the first token of the line