getopt: fix null pointer arithmetic ub
[musl] / src / network / dn_skipname.c
1 #include <resolv.h>
2
3 int dn_skipname(const unsigned char *s, const unsigned char *end)
4 {
5         const unsigned char *p = s;
6         while (p < end)
7                 if (!*p) return p-s+1;
8                 else if (*p>=192)
9                         if (p+1<end) return p-s+2;
10                         else break;
11                 else
12                         if (end-p<*p+1) break;
13                         else p += *p + 1;
14         return -1;
15 }