simsong / be20_api

API for bulk_extractor version 1.3
Other
12 stars 9 forks source link

replace stl regex with Google's re2 #104

Closed simsong closed 7 months ago

simsong commented 10 months ago
simsong commented 10 months ago

Yay! This makes std::regex hang:

    rv.clear();
    rv.push_back("[a-z]*@company.com");

    /* Make a 32MB array to search */
    std::string bigstring = std::string(1024*1024*30,'a') + " user@company.com " + std::string(1024*1024*2,'b');
    found="";
    size_t offset = 0;
    size_t len = 0;
    REQUIRE(rv.search_all(bigstring, &found, &offset, &len) == true);
    REQUIRE(found == "user@company.com");
    REQUIRE(offset == 1024*1024*30+2);
    REQUIRE(len == 16 );
simsong commented 10 months ago

This only hangs for 60 seconds, then it crashes:


Yay! This makes std::regex hang:

    rv.clear();
    rv.push_back("[a-z]*@company.com");

    /* Make a 32MB array to search */
    std::string bigstring = std::string(1024*1024*30,'a') + " user@company.com " + std::string(1024*1024*2,'b');
    found="";
    size_t offset = 0;
    size_t len = 0;
    alarm(60);
    REQUIRE(rv.search_all(bigstring, &found, &offset, &len) == true);
    alarm(0);
    REQUIRE(found == "user@company.com");
    REQUIRE(offset == 1024*1024*30+2);
    REQUIRE(len == 16 );