__libc_res_nquerydomain(res_state statp,
			const char *name,
			const char *domain,
			int class, int type,	/* class and type of query */
			u_char *answer,		/* buffer to put answer */
			int anslen,			/* size of answer */
			u_char **answerp,
			u_char **answerp2,
			int *nanswerp2,
			int *resplen2,
			int *answerp2_malloced)
{
	char nbuf[MAXDNAME];
	const char *longname = nbuf;
	size_t n, d;

#ifdef DEBUG
	if (statp->options & RES_DEBUG)
		printf(";; res_nquerydomain(%s, %s, %d, %d)\n",
		       name, domain?domain:"<Nil>", class, type);
#endif
	if (domain == NULL) {
		n = strlen(name);

		/* Decrement N prior to checking it against MAXDNAME
		   so that we detect a wrap to SIZE_MAX and return
		   a reasonable error.  */
		n--;
		if (n >= MAXDNAME - 1) {
			RES_SET_H_ERRNO(statp, NO_RECOVERY);
			return (-1);
		}
		longname = name;
	} else {
		n = strlen(name);
		d = strlen(domain);
		if (n + d + 1 >= MAXDNAME) {
			RES_SET_H_ERRNO(statp, NO_RECOVERY);
			return (-1);
		}
		sprintf(nbuf, "%s.%s", name, domain);
	}
	return (__libc_res_nquery(statp, longname, class, type, answer,
				  anslen, answerp, answerp2, nanswerp2,
				  resplen2, answerp2_malloced));
}
__libc_res_nquerydomain(res_state statp,
			const char *name,
			const char *domain,
			int class, int type,	 
			u_char *answer,		 
			int anslen,			 
			u_char **answerp,
			u_char **answerp2,
			int *nanswerp2,
			int *resplen2,
			int *answerp2_malloced)
{
	char nbuf[MAXDNAME];
	const char *longname = nbuf;
	size_t n, d;

#ifdef DEBUG
	if (statp->options & RES_DEBUG)
		printf(";; res_nquerydomain(%s, %s, %d, %d)\n",
		       name, domain?domain:"<Nil>", class, type);
#endif
	if (domain == NULL) {
		n = strlen(name);

		 
		n--;
		if (n >= MAXDNAME - 1) {
			RES_SET_H_ERRNO(statp, NO_RECOVERY);
			return (-1);
		}
		longname = name;
	} else {
		n = strlen(name);
		d = strlen(domain);
		if (n + d + 1 >= MAXDNAME) {
			RES_SET_H_ERRNO(statp, NO_RECOVERY);
			return (-1);
		}
		sprintf(nbuf, "%s.%s", name, domain);
	}
	return (__libc_res_nquery(statp, longname, class, type, answer,
				  anslen, answerp, answerp2, nanswerp2,
				  resplen2, answerp2_malloced));
}