diff options
author | Denys Vlasenko | 2023-05-09 19:32:29 +0200 |
---|---|---|
committer | Denys Vlasenko | 2023-05-09 19:32:29 +0200 |
commit | dc84002a8256feb1cc7f0fb70bdbfc998deeba4a (patch) | |
tree | f46e8b826fda198b54138ae09aecbd2b1bbce93b /networking/nslookup.c | |
parent | 62775ec4b34bd2a1b5e4c60aa40ba67bd979069a (diff) | |
download | busybox-dc84002a8256feb1cc7f0fb70bdbfc998deeba4a.zip busybox-dc84002a8256feb1cc7f0fb70bdbfc998deeba4a.tar.gz |
nslookup: code shrink
function old new delta
send_queries 725 723 -2
nslookup_main 822 820 -2
add_query 89 86 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-7) Total: -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/nslookup.c')
-rw-r--r-- | networking/nslookup.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c index 24eae40..249083e 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -589,6 +589,7 @@ static int RESOLVFUNC res_mkquery(int op, const char *dname, int class, int type if (l>253 || buflen<n || op>15u || class>255u || type>255u) return -1; +//TODO: why do we even have the q[] array? Use buf[] directly! /* Construct query template - ID will be filled later */ memset(q, 0, n); q[2] = op*8 + 1; @@ -637,7 +638,12 @@ struct query { unsigned qlen; // unsigned latency; // uint8_t rcode; - unsigned char query[512]; + /* res_mkquery() balks on names > 253 chars. + * The formed query is 253+18 chars at max. + * Real hostnames are nowhere near that long anyway. + * Use of power-of-2 size means smaller code. + */ + unsigned char query[512 - sizeof(int) - sizeof(char*)]; // unsigned char reply[512]; }; |