Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/nameser/ns_name.c
Show First 20 Lines • Show All 678 Lines • ▼ Show 20 Lines | |||||
* return: | * return: | ||||
*\li 0 on success, -1 (with errno set) on failure. | *\li 0 on success, -1 (with errno set) on failure. | ||||
*/ | */ | ||||
int | int | ||||
ns_name_skip(const u_char **ptrptr, const u_char *eom) | ns_name_skip(const u_char **ptrptr, const u_char *eom) | ||||
{ | { | ||||
const u_char *cp; | const u_char *cp; | ||||
u_int n; | u_int n; | ||||
int l; | int l = 0; | ||||
cp = *ptrptr; | cp = *ptrptr; | ||||
while (cp < eom && (n = *cp++) != 0) { | while (cp < eom && (n = *cp++) != 0) { | ||||
/* Check for indirection. */ | /* Check for indirection. */ | ||||
switch (n & NS_CMPRSFLGS) { | switch (n & NS_CMPRSFLGS) { | ||||
case 0: /*%< normal case, n == len */ | case 0: /*%< normal case, n == len */ | ||||
cp += n; | cp += n; | ||||
continue; | continue; | ||||
case NS_TYPE_ELT: /*%< EDNS0 extended label */ | case NS_TYPE_ELT: /*%< EDNS0 extended label */ | ||||
if ((l = labellen(cp - 1)) < 0) { | if (cp < eom && (l = labellen(cp - 1)) < 0) { | ||||
errno = EMSGSIZE; /*%< XXX */ | errno = EMSGSIZE; /*%< XXX */ | ||||
return (-1); | return (-1); | ||||
} | } | ||||
cp += l; | cp += l; | ||||
continue; | continue; | ||||
case NS_CMPRSFLGS: /*%< indirection */ | case NS_CMPRSFLGS: /*%< indirection */ | ||||
cp++; | cp++; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 453 Lines • Show Last 20 Lines |