dnsproxy: Fix cached ttl update
PATCH 1/1 dnsproxy: Fix cached ttl update
This bug was exposed after fixing the signedness comparison warnings found in dnsproxy.c update_cached_ttl() consistently comes up two bytes short when processing the last record.
--- src/dnsproxy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
src/dnsproxy.c +1 -2
@@ -508,8 +508,7 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len,if (answers ==0 ) hdr->aa =1 ;else { -const int adj_len = len -2 ; -update_cached_ttl ((unsigned char *)hdr, adj_len, ttl); +update_cached_ttl ((unsigned char *)hdr, len, ttl); } debug("sk %d id 0x%04x answers %d ptr %p length %zd dns %zd",
Signature · 1 line
2.34.1
Hi Brian,
Quoted 12 lines · Brian Fukano
This bug was exposed after fixing the signedness comparison warnings found in
dnsproxy.cupdate_cached_ttl()consistently comes up two bytes short when processing the last record.--- src/dnsproxy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)src/dnsproxy.c +0
-0
src/dnsproxy.c static void send_cached_response(int sk, const unsigned char *ptr, size_t len, · line 511
Quoted 6 lines
src/dnsproxy.c +1
-2@@ -508,8 +508,7 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len,if (answers ==0 ) hdr->aa =1 ;else { -const int adj_len = len -2 ; -update_cached_ttl ((unsigned char *)hdr, adj_len, ttl); +update_cached_ttl ((unsigned char *)hdr, len, ttl);
Looks like this should be dns_len? Also, the { } around the else are no longer needed.
src/dnsproxy.c static void send_cached_response(int sk, const unsigned char *ptr, size_t len, · line 514
Quoted 3 lines
src/dnsproxy.c +0
-0} debug("sk %d id 0x%04x answers %d ptr %p length %zd dns %zd",
Regards,
-Denis