1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00
This commit is contained in:
Jakub Jelinek
2007-07-12 18:26:36 +00:00
parent 7d58530341
commit 0ecb606cb6
6215 changed files with 494638 additions and 305010 deletions

View File

@@ -124,10 +124,6 @@ res_nmkquery(res_state statp,
incremented by one after the initial randomization which
still predictable if the application does multiple
requests. */
#if 0
hp->id = htons(++statp->id);
#else
hp->id = htons(statp->id);
int randombits;
do
{
@@ -141,7 +137,7 @@ res_nmkquery(res_state statp,
}
while ((randombits & 0xffff) == 0);
statp->id = (statp->id + randombits) & 0xffff;
#endif
hp->id = statp->id;
hp->opcode = op;
hp->rd = (statp->options & RES_RECURSE) != 0;
hp->rcode = NOERROR;
@@ -155,38 +151,36 @@ res_nmkquery(res_state statp,
* perform opcode specific processing
*/
switch (op) {
case QUERY: /*FALLTHROUGH*/
case NS_NOTIFY_OP:
if ((buflen -= QFIXEDSZ + (data == NULL ? 0 : RRFIXEDSZ)) < 0)
return (-1);
goto compose;
case QUERY:
if ((buflen -= QFIXEDSZ) < 0)
return (-1);
compose:
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
return (-1);
cp += n;
buflen -= n;
__putshort(type, cp);
cp += INT16SZ;
__putshort(class, cp);
cp += INT16SZ;
NS_PUT16 (type, cp);
NS_PUT16 (class, cp);
hp->qdcount = htons(1);
if (op == QUERY || data == NULL)
break;
/*
* Make an additional record for completion domain.
*/
buflen -= RRFIXEDSZ;
n = dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr);
if (n < 0)
if (__builtin_expect (n < 0, 0))
return (-1);
cp += n;
buflen -= n;
__putshort(T_NULL, cp);
cp += INT16SZ;
__putshort(class, cp);
cp += INT16SZ;
__putlong(0, cp);
cp += INT32SZ;
__putshort(0, cp);
cp += INT16SZ;
NS_PUT16 (T_NULL, cp);
NS_PUT16 (class, cp);
NS_PUT32 (0, cp);
NS_PUT16 (0, cp);
hp->arcount = htons(1);
break;
@@ -194,17 +188,13 @@ res_nmkquery(res_state statp,
/*
* Initialize answer section
*/
if (buflen < 1 + RRFIXEDSZ + datalen)
if (__builtin_expect (buflen < 1 + RRFIXEDSZ + datalen, 0))
return (-1);
*cp++ = '\0'; /* no domain name */
__putshort(type, cp);
cp += INT16SZ;
__putshort(class, cp);
cp += INT16SZ;
__putlong(0, cp);
cp += INT32SZ;
__putshort(datalen, cp);
cp += INT16SZ;
NS_PUT16 (type, cp);
NS_PUT16 (class, cp);
NS_PUT32 (0, cp);
NS_PUT16 (datalen, cp);
if (datalen) {
memcpy(cp, data, datalen);
cp += datalen;