From cff2c78c513ef8d51e69a6933f1c6aef8a24a6d6 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 19 Jul 2021 07:55:27 +0200 Subject: 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 --- resolv/ns_name.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'resolv/ns_name.c') diff --git a/resolv/ns_name.c b/resolv/ns_name.c index a0d541f..58d6a60 100644 --- a/resolv/ns_name.c +++ b/resolv/ns_name.c @@ -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. */ /*% -- cgit v1.1