1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

resolv: Move ns_name_skip to its own file and into libc (bug 28091)

And reformat to GNU style.  Avoid out-of-bounds pointer arithmetic.
This also results in a fix of bug 28091 due to the additional packet
length checks.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Carlos O'Donell <carlos@systemhalted.org>
This commit is contained in:
Florian Weimer
2021-07-19 07:55:27 +02:00
parent 248dbed118
commit cff2c78c51
69 changed files with 143 additions and 70 deletions

View File

@@ -397,43 +397,6 @@ ns_name_rollback(const u_char *src, const u_char **dnptrs,
}
}
/*%
* Advance *ptrptr to skip over the compressed name it points at.
*
* return:
*\li 0 on success, -1 (with errno set) on failure.
*/
int
ns_name_skip(const u_char **ptrptr, const u_char *eom)
{
const u_char *cp;
u_int n;
cp = *ptrptr;
while (cp < eom && (n = *cp++) != 0) {
/* Check for indirection. */
switch (n & NS_CMPRSFLGS) {
case 0: /*%< normal case, n == len */
cp += n;
continue;
case NS_CMPRSFLGS: /*%< indirection */
cp++;
break;
default: /*%< illegal type */
__set_errno (EMSGSIZE);
return (-1);
}
break;
}
if (cp > eom) {
__set_errno (EMSGSIZE);
return (-1);
}
*ptrptr = cp;
return (0);
}
libresolv_hidden_def (ns_name_skip)
/* Private. */
/*%