You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We just ran into the same problem (which led to CPU-intensive never-ending loops) and we believe adding the parenthesis as in the last snippet is the correct way to fix this.
pos = (highbyte & 63) << 8 | current->data[pos];
(line 54 should also be changed similarly)
We also have found other issues with the way DNS compression is handled in dns.c, so we may propose a PR soon.
In https://github.com/jbangert/nail/blob/master/examples/dns/dns.c there is this snippet:
or
In C, the operator precedence is <<, then &, then |, so that the equivalent parenthesized expression is:
Folding the 63<<8 constant gives:
highbyte is a uint8_t, obviously in the range [0x00, 0xFF], so and'ing it with 0x3F00 will always be zero:
which simplifies to:
which is:
which is clearly an error, as it ignores the highbyte value. Presumably the original statement should have been:
although it's not obvious if that is still semantically correct, for compressed DNS records.
The text was updated successfully, but these errors were encountered: