Skip to content

Commit

Permalink
* resolv/res_query.c (__libc_res_nquery): Align buffer for T_AAAA
Browse files Browse the repository at this point in the history
	query.  Adjust buffer size computation for padding.
  • Loading branch information
Ulrich Drepper committed Jul 9, 2008
1 parent 75684bd commit 44abc39
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2008-07-09 Ulrich Drepper <drepper@redhat.com>

* resolv/res_query.c (__libc_res_nquery): Align buffer for T_AAAA
query. Adjust buffer size computation for padding.

2008-07-08 Ulrich Drepper <drepper@redhat.com>

* stdio-common/Makefile: Add rules to build and run tst-setvbuf1.
Expand Down
24 changes: 20 additions & 4 deletions resolv/res_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,34 @@ __libc_res_nquery(res_state statp,
{
if ((oflags & RES_F_EDNS0ERR) == 0
&& (statp->options & RES_USE_EDNS0) != 0)
n = __res_nopt(statp, n, query1, bufsize, anslen / 2);
{
n = __res_nopt(statp, n, query1, bufsize, anslen / 2);
if (n < 0)
goto unspec_nomem;
}

nquery1 = n;
query2 = buf + nquery1;
/* Align the buffer. */
int npad = ((nquery1 + __alignof__ (HEADER) - 1)
& ~(__alignof__ (HEADER)));
if (n > bufsize - npad)
{
n = -1;
goto unspec_nomem;
}
query2 = buf + npad;
int nused = n + npad;
n = res_nmkquery(statp, QUERY, name, class, T_AAAA, NULL, 0,
NULL, query2, bufsize - n);
NULL, query2, bufsize - nused);
if (n > 0
&& (oflags & RES_F_EDNS0ERR) == 0
&& (statp->options & RES_USE_EDNS0) != 0)
n = __res_nopt(statp, n, query2, bufsize - n, anslen / 2);
n = __res_nopt(statp, n, query2, bufsize - nused - n,
anslen / 2);
nquery2 = n;
}

unspec_nomem:;
}
else
{
Expand Down

0 comments on commit 44abc39

Please sign in to comment.