summaryrefslogtreecommitdiff
path: root/src/dnsproxy.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-04-07 17:52:37 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-04-08 09:16:39 +0300
commit5119c432d09946864ba8179da319578750226b3b (patch)
tree10226575bf2fd0f1f73a413e7e17d4847a37e02a /src/dnsproxy.c
parent40efa0d29e0f0b41e445003bd3026272b5e59e4b (diff)
downloadconnman-5119c432d09946864ba8179da319578750226b3b.tar.gz
connman-5119c432d09946864ba8179da319578750226b3b.tar.bz2
connman-5119c432d09946864ba8179da319578750226b3b.zip
dnsproxy: Fix cached message length correctly
We must copy the response buffer before fixing the packet length. Otherwise the packet length will go wrong if the request contained EDNS0 data.
Diffstat (limited to 'src/dnsproxy.c')
-rw-r--r--src/dnsproxy.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 388ea4bf..52d67d4a 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1556,12 +1556,16 @@ static int cache_update(struct server_data *srv, unsigned char *msg,
* two bytes. This way we do not need to know the format
* (UDP/TCP) of the cached message.
*/
+ if (srv->protocol == IPPROTO_UDP)
+ memcpy(ptr + 2, msg, offset + 12);
+ else
+ memcpy(ptr, msg, offset + 12);
+
ptr[0] = (data->data_len - 2) / 256;
ptr[1] = (data->data_len - 2) - ptr[0] * 256;
if (srv->protocol == IPPROTO_UDP)
ptr += 2;
- memcpy(ptr, msg, offset + 12);
memcpy(ptr + offset + 12, question, qlen + 1); /* copy also the \0 */
q = (void *) (ptr + offset + 12 + qlen + 1);