Updating ttl on the cached DNS response causes data access misaligned
on the blackfin architeture.
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index e0b8da2..ad86979 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -322,7 +322,6 @@ static int dns_name_length(unsigned char *buf)
static void update_cached_ttl(unsigned char *buf, int len, int new_ttl)
{
unsigned char *c;
- uint32_t *i;
uint16_t *w;
int l;
@@ -353,8 +352,20 @@ static void update_cached_ttl(unsigned char *buf,
int len, int new_ttl)
break;
/* now the 4 byte TTL field */
- i = (uint32_t *)c;
- *i = htonl(new_ttl);
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ c[0] = (new_ttl >> 24) & 0xff;
+ c[1] = (new_ttl >> 16) & 0xff;
+ c[2] = (new_ttl >> 8) & 0xff;
+ c[3] = new_ttl & 0xff;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ c[0] = new_ttl & 0xff;
+ c[1] = (new_ttl >> 8) & 0xff;
+ c[2] = (new_ttl >> 16) & 0xff;
+ c[3] = (new_ttl >> 24) & 0xff;
+#else
+#error "Unknown byte order"
+#endif
+
c += 4;
len -= 4;
if (len < 0)
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman