Browse Source

only put NFC-compliant strings into address and text header fields to the Engine, as desired. TODO: use view/range-based approach to avoid copying. :-|

afl-fuzzing
Roker 3 years ago
parent
commit
f06b9ccf5c
2 changed files with 9 additions and 5 deletions
  1. +6
    -3
      src/headerparser.cc
  2. +3
    -2
      src/parse_address.cc

+ 6
- 3
src/headerparser.cc View File

@ -1,4 +1,5 @@
#include "pEpMIME_internal.hh"
#include "nfc.hh"
#include "parse_address.hh"
#include "parse_timestamp.hh"
#include "rules.hh"
@ -20,7 +21,7 @@ namespace pEpMIME
typedef std::vector<std::string> DS;
const Rule mchar = +(qi::char_ - qi::char_("<>\\()")); // 8-bit octets are "negative" so put them in reverse order for ranges.
const Rule mchar = +(qi::char_ - qi::char_("<>\\()")); // accept more char values than RFC requires.
const Rule message_id = qi::omit[ *qi::char_("\t\n\r ")] >> qi::lit('<') >> mchar >> qi::lit('>');
const qi::rule<std::string::const_iterator, DS() > message_id_list = *message_id;
@ -120,7 +121,8 @@ TRuleParser<T1, T2>* P(T2 message::* member, const qi::rule<std::string::const_i
// make sure the C string is allocated on the correct heap, especially on MS Windows. *sigh*
char* copy_string(const std::string& s)
{
return new_string(s.c_str(), s.size());
const std::string nfc = toNFC(s); // TODO: use views/ranges to avoid copying
return new_string(nfc.c_str(), nfc.size());
}
@ -153,7 +155,8 @@ void parse_header(message* msg, const HeaderSection& header)
if(p == parsers.end())
{
// unknown header with no special parser: just dump it in opt_fields
auto sp = new_stringpair( h.name.c_str(), h.value.c_str() );
const std::string nfc = toNFC(h.value); // TODO: use views/ranges to avoid copying
auto sp = new_stringpair( h.name.c_str(), nfc.c_str() );
auto f = stringpair_list_add( msg->opt_fields, sp);
// the function above has a strange semantic:


+ 3
- 2
src/parse_address.cc View File

@ -1,4 +1,5 @@
#include "parse_address.hh"
#include "nfc.hh"
#include "rules.hh"
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
@ -70,7 +71,7 @@ pEp_identity* parse_address(const std::string& s)
// std::cerr << " ===\n";
return new_identity(iden.address.c_str(), nullptr, nullptr, iden.name.c_str());
return new_identity(toNFC(iden.address).c_str(), nullptr, nullptr, toNFC(iden.name).c_str());
}
@ -96,7 +97,7 @@ identity_list* parse_address_list(const std::string& s)
identity_list* iter = iden_list;
for(const auto& i : vi)
{
pEp_identity* iden = new_identity( i.address.c_str(), nullptr, nullptr, i.name.c_str());
pEp_identity* iden = new_identity( toNFC(i.address).c_str(), nullptr, nullptr, toNFC(i.name).c_str());
identity_list_add( iter, iden );
}


Loading…
Cancel
Save