X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=dns.c;h=3f508271672e19584fe1bbab230492d294ae8df5;hb=b8c78f5c0da93d92aa28d3ef3757e78d03141f41;hp=d518a305690dac40adf4eb14ae4b0ce872e1e179;hpb=4c8155fa9c85c7ece92182d0ab53f99a982a4abf;p=catta diff --git a/dns.c b/dns.c index d518a30..3f50827 100644 --- a/dns.c +++ b/dns.c @@ -63,8 +63,8 @@ guint16 flx_dns_packet_get_field(flxDnsPacket *p, guint index) { return g_ntohs(((guint16*) FLX_DNS_PACKET_DATA(p))[index]); } -/* Read the first label from string dest, unescape "\" and append it to *name */ -static gchar *unescape_label(gchar *dest, guint size, const gchar **name) { +/* Read the first label from string *name, unescape "\" and write it to dest */ +gchar *flx_unescape_label(gchar *dest, guint size, const gchar **name) { guint i = 0; gchar *d; @@ -119,7 +119,7 @@ guint8* flx_dns_packet_append_name(flxDnsPacket *p, const gchar *name) { guint n; guint8* prev; const gchar *pname; - char label[64]; + gchar label[64]; /* Check whether we can compress this name. */ @@ -143,7 +143,7 @@ guint8* flx_dns_packet_append_name(flxDnsPacket *p, const gchar *name) { pname = name; - if (!(unescape_label(label, sizeof(label), &name))) + if (!(flx_unescape_label(label, sizeof(label), &name))) goto fail; if (!(d = flx_dns_packet_append_string(p, label))) @@ -482,9 +482,12 @@ flxRecord* flx_dns_packet_consume_record(flxDnsPacket *p, gboolean *ret_cache_fl goto fail; /* g_message("name = %s, rdlength = %u", name, rdlength); */ + + *ret_cache_flush = !!(class & FLX_DNS_CACHE_FLUSH); + class &= ~ FLX_DNS_CACHE_FLUSH; start = flx_dns_packet_get_rptr(p); - + r = flx_record_new_full(name, class, type); switch (type) { @@ -581,9 +584,6 @@ flxRecord* flx_dns_packet_consume_record(flxDnsPacket *p, gboolean *ret_cache_fl if ((guint8*) flx_dns_packet_get_rptr(p) - (guint8*) start != rdlength) goto fail; - *ret_cache_flush = !!(class & FLX_DNS_CACHE_FLUSH); - class &= ~ FLX_DNS_CACHE_FLUSH; - r->ttl = ttl; return r;