Created
July 16, 2020 18:28
Revisions
-
DRiKE created this gist
Jul 16, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ static __always_inline uint8_t *parse_dname(struct cursor *c, uint8_t *pkt) { uint8_t *dname = c->pos; int i; for (i = 0; i < 128; i++) { /* Maximum 128 labels */ uint8_t o; if (c->pos + 1 > c->end) return 0; o = *(uint8_t *)c->pos; if ((o & 0xC0) == 0xC0) { /* Compression label, Only back references! */ if ((o | 0x3F) >= (dname - pkt)) return 0; /* Compression label is the last label of a dname. */ c->pos += 1; break; } else if (o & 0xC0) /* Unknown label type */ return 0; c->pos += o + 1; if (!o) break; } return dname; }