/* Skip encoded FQDN in DNS message. Returns size in bytes of encoded FQDN, or negative error code.  */
static int skip_fqdn(uint8_t *answer, int buf_sz)
/* Skip encoded FQDN in DNS message. Returns size in bytes of encoded FQDN, or negative error code.  */
static int skip_fqdn(uint8_t *answer, int buf_sz)
{
	int i = 0;
	while (1) {
		if (i >= buf_sz) {
			return -EINVAL;
		}
		if (answer[i] == 0) {
			i += 1;
			break;
		} else if (answer[i] >= 0xc0) {
			i += 2;
			if (i > buf_sz) {
				return -EINVAL;
			}
			break;
		} else if (answer[i] < DNS_LABEL_MAX_SIZE) {
			i += answer[i] + 1;
		} else {
			return -EINVAL;
		}
	}
	return i;
}