dn = exp_dn; cp = comp_dn; eom = exp_dn + length;  while (n = *cp++) {  switch (n & INDIR_MASK) { case 0: octets += (n + 1); if (octets > MAXCDNAME) return (-1); if (dn != exp_dn) { if (dn >= eom) return (-1); *dn++ = '.'; } if (dn+n >= eom) return (-1); checked += n + 1; while (--n >= 0) { if (((c = *cp++) == '.') || (c == '\\')) { if (dn + n + 2 >= eom) return (-1); *dn++ = '\\'; } *dn++ = c; if (cp >= eomorig)	 return (-1); } break;  case INDIR_MASK: if (len < 0) len = cp - comp_dn + 1; cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff)); if (cp < msg || cp >= eomorig)	 return (-1); checked += 2;  if (checked >= eomorig - msg) return (-1); break;  default: return (-1);			 } } *dn = '\0'; if (len < 0) len = cp - comp_dn; return (len);
if (n > 0 && dst[0] == '.') dst[0] = '\0'; return (n);
dn_expand(msg, eomorig, comp_dn, exp_dn, length)	const u_char *msg, *eomorig, *comp_dn;	char *exp_dn;	int length;{	register const u_char *cp;	register char *dn;	register int n, c;	char *eom;	int len = -1, checked = 0, octets = 0;	dn = exp_dn;	cp = comp_dn;	eom = exp_dn + length;	/*	 * fetch next label in domain name	 */	while (n = *cp++) {		/*		 * Check for indirection		 */		switch (n & INDIR_MASK) {		case 0:			octets += (n + 1);			if (octets > MAXCDNAME)				return (-1);			if (dn != exp_dn) {				if (dn >= eom)					return (-1);				*dn++ = '.';			}			if (dn+n >= eom)				return (-1);			checked += n + 1;			while (--n >= 0) {				if (((c = *cp++) == '.') || (c == '\\')) {					if (dn + n + 2 >= eom)						return (-1);					*dn++ = '\\';				}				*dn++ = c;				if (cp >= eomorig)	/* out of range */					return (-1);			}			break;		case INDIR_MASK:			if (len < 0)				len = cp - comp_dn + 1;			cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));			if (cp < msg || cp >= eomorig)	/* out of range */				return (-1);			checked += 2;			/*			 * Check for loops in the compressed name;			 * if we've looked at the whole message,			 * there must be a loop.			 */			if (checked >= eomorig - msg)				return (-1);			break;		default:			return (-1);			/* flag error */		}	}	*dn = '\0';	if (len < 0)		len = cp - comp_dn;	return (len);}