[RFC] resolv: Align buf before second query for A_AAA in __res_context_query
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
Re-introduces alignment handling that was removed by patch 40c0add7d487
("resolve: Remove __res_context_query alloca usage")
Verfied by successfully running the resolv test suite on sparc32.
Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
---
resolv/res_query.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
@@ -147,9 +147,19 @@ __res_context_query (struct resolv_context *ctx, const char *name,
}
nquery1 = n;
- query2 = buf.data + n;
+ /* Align the buffer. */
+ int npad = ((nquery1 + __alignof__ (HEADER) - 1)
+ & ~(__alignof__ (HEADER) - 1)) - nquery1;
+ if (n > buf.length - npad)
+ {
+ n = -1;
+ goto unspec_nomem;
+ }
+
+ int nused = n + npad;
+ query2 = buf.data + nused;
n = __res_context_mkquery (ctx, QUERY, name, class, T_AAAA,
- NULL, query2, buf.length - n);
+ NULL, query2, buf.length - nused);
if (n > 0
&& (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0)
/* Use RESOLV_EDNS_BUFFER_SIZE because the receive