Browse Source

handle header lines with name but no value after the ':'

afl-fuzzing
Roker 3 years ago
parent
commit
02844e2d37
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      src/pEpMIME.cc

+ 9
- 6
src/pEpMIME.cc View File

@ -129,27 +129,30 @@ message* parse_message2(const char* begin, const char* const end)
NameValue nv;
for(int i=0; i<headersize; ++i)
{
sv line = lines[i];
sv line = lines.at(i);
const int lineType = header_line_type(line);
LOG << "Line #" << i << ": \"" << line << "\". type=" << lineType << ". \n";
switch(lineType)
{
case -2: // line is bogus. But be robust: just skip that line and hope for the best...
//throw std::runtime_error("Cannot handle line \"" + std::string(line) + "\""); return nullptr; // TODO: C'mon, don't give up, yet! :-)
continue;
break;
case -1: nv.value += std::string(line);
break;
break;
default:
{
if(!nv.name.empty())
{
headers.push_back(nv);
}
const int firstBody = lineType + 1; // 1st index _after_ the ':'
const char firstBodyChar = line.at(firstBody); // if SPACE or TAB char: chop this char, too. but only the 1st!
nv.name = std::string( line.substr(0, lineType) );
ascii_tolower(nv.name);
nv.value = std::string( line.substr( firstBody + ( (firstBodyChar==' '|| firstBodyChar=='\t') ? 1 : 0) ));
const int firstBody = lineType + 1; // 1st index _after_ the ':'
if(firstBody < line.size()) // there is something after the ':'
{
const char firstBodyChar = line.at(firstBody); // if SPACE or TAB char: chop this char, too. but only the 1st!
nv.value = std::string( line.substr( firstBody + ( (firstBodyChar==' '|| firstBodyChar=='\t') ? 1 : 0) ));
}
}
}
}


Loading…
Cancel
Save