Rich Felker | b6f9941 | 2013-04-04 22:36:30 -0400 | [diff] [blame] | 1 | #include <resolv.h> |
| 2 | |
| 3 | int dn_skipname(const unsigned char *s, const unsigned char *end) |
| 4 | { |
Ryan Fairfax | 2a0ff45 | 2019-03-07 13:20:54 -0800 | [diff] [blame^] | 5 | const unsigned char *p = s; |
| 6 | while (p < end) |
Rich Felker | b6f9941 | 2013-04-04 22:36:30 -0400 | [diff] [blame] | 7 | if (!*p) return p-s+1; |
| 8 | else if (*p>=192) |
| 9 | if (p+1<end) return p-s+2; |
| 10 | else break; |
Ryan Fairfax | 2a0ff45 | 2019-03-07 13:20:54 -0800 | [diff] [blame^] | 11 | else |
| 12 | if (end-p<*p+1) break; |
| 13 | else p += *p + 1; |
Rich Felker | b6f9941 | 2013-04-04 22:36:30 -0400 | [diff] [blame] | 14 | return -1; |
| 15 | } |