aboutsummaryrefslogtreecommitdiffstats
path: root/src/dns.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-18 18:40:46 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-18 18:40:46 +0300
commitc22c8be47f7ef8e3018dbb301f65f512b4e83535 (patch)
tree95af66fd03b9542e58e586c316d900fc426ec2ab /src/dns.c
parent474b4f809c7321c47c0ddc68b563dd69cbf2cef9 (diff)
downloadrspamd-c22c8be47f7ef8e3018dbb301f65f512b4e83535.tar.gz
rspamd-c22c8be47f7ef8e3018dbb301f65f512b4e83535.zip
Optimize DNS parsing.
Suggested by: Igor Sysoev
Diffstat (limited to 'src/dns.c')
-rw-r--r--src/dns.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dns.c b/src/dns.c
index 4070c4905..82c796c1e 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -755,8 +755,8 @@ end:
return TRUE;
}
-#define GET16(x) do {if (*remain < sizeof (guint16)) {goto err;} memcpy (&(x), p, sizeof (guint16)); (x) = ntohs ((x)); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0)
-#define GET32(x) do {if (*remain < sizeof (guint32)) {goto err;} memcpy (&(x), p, sizeof (guint32)); (x) = ntohl ((x)); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0)
+#define GET16(x) do {(x) = ((*p) << 8) + *(p + 1); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0)
+#define GET32(x) do {(x) = ((*p) << 24) + ((*(p + 1)) << 16) + ((*(p + 2)) << 8) + *(p + 3); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0)
static gint
dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, gint *remain)