freewrt_2_0
| Rev | Line | |
|---|
| [3422ee7] | 1 | #include <errno.h>
|
|---|
| 2 | #include <resolv.h>
|
|---|
| 3 |
|
|---|
| 4 | /* Ripped from glibc 2.4 sources. */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * ns_name_skip(ptrptr, eom)
|
|---|
| 8 | * Advance *ptrptr to skip over the compressed name it points at.
|
|---|
| 9 | * return:
|
|---|
| 10 | * 0 on success, -1 (with errno set) on failure.
|
|---|
| 11 | */
|
|---|
| 12 | int ns_name_skip(const u_char **ptrptr, const u_char *eom)
|
|---|
| 13 | {
|
|---|
| 14 | const u_char *cp;
|
|---|
| 15 | u_int n;
|
|---|
| 16 |
|
|---|
| 17 | cp = *ptrptr;
|
|---|
| 18 | while (cp < eom && (n = *cp++) != 0)
|
|---|
| 19 | {
|
|---|
| 20 | /* Check for indirection. */
|
|---|
| 21 | switch (n & NS_CMPRSFLGS) {
|
|---|
| 22 | case 0: /* normal case, n == len */
|
|---|
| 23 | cp += n;
|
|---|
| 24 | continue;
|
|---|
| 25 | case NS_CMPRSFLGS: /* indirection */
|
|---|
| 26 | cp++;
|
|---|
| 27 | break;
|
|---|
| 28 | default: /* illegal type */
|
|---|
| 29 | errno = EMSGSIZE;
|
|---|
| 30 | return (-1);
|
|---|
| 31 | }
|
|---|
| 32 | break;
|
|---|
| 33 | }
|
|---|
| 34 | if (cp > eom)
|
|---|
| 35 | {
|
|---|
| 36 | errno = EMSGSIZE;
|
|---|
| 37 | return (-1);
|
|---|
| 38 | }
|
|---|
| 39 | *ptrptr = cp;
|
|---|
| 40 | return (0);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | int dn_skipname(const u_char *ptr, const u_char *eom)
|
|---|
| 44 | {
|
|---|
| 45 | const u_char *saveptr = ptr;
|
|---|
| 46 |
|
|---|
| 47 | if(ns_name_skip(&ptr, eom) == -1)
|
|---|
| 48 | return (-1);
|
|---|
| 49 | return (ptr - saveptr);
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.