NLnetLabs / simdzone

Fast and standards compliant DNS zone parser
BSD 3-Clause "New" or "Revised" License
63 stars 11 forks source link

Fix contiguous scan of escaped content #203

Closed wcawijngaards closed 2 months ago

wcawijngaards commented 2 months ago

Fix contiguous scan that starts is_escaped, this fixes the parsing of unknown RR types.

k0ekk0ek commented 2 months ago

@wcawijngaards, how about? At least, this makes the test pass, so I suspect for the test it reads the \\ just on the boundary(?)

diff --git a/src/fallback/scanner.h b/src/fallback/scanner.h
index c84f31c..297f75d 100644
--- a/src/fallback/scanner.h
+++ b/src/fallback/scanner.h
@@ -70,12 +70,11 @@ static really_inline const char *scan_contiguous(
   while (start < end) {
     if (likely(classify[ (uint8_t)*start ] == CONTIGUOUS)) {
       if (unlikely(*start == '\\')) {
-escaped:
         if ((parser->file->state.is_escaped = (++start == end)))
           break;
+escaped:
         assert(start < end);
         parser->file->newlines.tail[0] += (*start == '\n');
-       continue;
       }
       start++;
     } else {
wcawijngaards commented 2 months ago

Wouldn't that fail on a scan of a one character segment? With the value of is_escaped wrong at exit of the routine?

wcawijngaards commented 2 months ago

No, I think it would fail on a zero length segment in the incoming call. Perhaps zero length segments do not happen, and then it would fine for me.