diff options
author | Ulrich Drepper <drepper@redhat.com> | 2008-07-09 17:59:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2008-07-09 17:59:15 +0000 |
commit | 44abc397e6203bbb46e73acee48e7ffd17e1f90a (patch) | |
tree | 6ec3071da94122034af4b1f33d290d7ecdee93b1 /resolv | |
parent | 75684bd7a8e660feeac0e8fa3464af8c190cf1f2 (diff) | |
download | glibc-44abc397e6203bbb46e73acee48e7ffd17e1f90a.tar.gz glibc-44abc397e6203bbb46e73acee48e7ffd17e1f90a.tar.xz glibc-44abc397e6203bbb46e73acee48e7ffd17e1f90a.zip |
* resolv/res_query.c (__libc_res_nquery): Align buffer for T_AAAA
query. Adjust buffer size computation for padding.
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/res_query.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c index 3d2f2fe3a9..d3a959f3b4 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -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 { |