summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-12-24 00:46:31 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-12-24 00:46:31 +0000
commitc6e30fe7be92b1fcbf50d764e3e5900ae5445984 (patch)
treedef80cb61c4da3636643ae1d5197e96f54558240 /src
parent2ddbd39ac4488f89f9c589bede1e296ca39b7ba4 (diff)
downloads6-dns-c6e30fe7be92b1fcbf50d764e3e5900ae5445984.tar.xz
s6dns_message_parse_question() needs to update counts
Diffstat (limited to 'src')
-rw-r--r--src/include/s6-dns/s6dns-message.h2
-rw-r--r--src/libs6dns/s6dns_message_parse_question.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/include/s6-dns/s6dns-message.h b/src/include/s6-dns/s6dns-message.h
index 614bf1a..4a89196 100644
--- a/src/include/s6-dns/s6dns-message.h
+++ b/src/include/s6-dns/s6dns-message.h
@@ -187,6 +187,6 @@ extern unsigned int s6dns_message_parse_next (s6dns_message_counts_t *, s6dns_me
/* For when you want to write a cache */
-extern int s6dns_message_parse_question (s6dns_domain_t *, uint16_t *, char const *, unsigned int, unsigned int *) ;
+extern int s6dns_message_parse_question (s6dns_message_counts_t *, s6dns_domain_t *, uint16_t *, char const *, unsigned int, unsigned int *) ;
#endif
diff --git a/src/libs6dns/s6dns_message_parse_question.c b/src/libs6dns/s6dns_message_parse_question.c
index e2b639f..170168c 100644
--- a/src/libs6dns/s6dns_message_parse_question.c
+++ b/src/libs6dns/s6dns_message_parse_question.c
@@ -8,13 +8,15 @@
#include <s6-dns/s6dns-constants.h>
#include <s6-dns/s6dns-message.h>
-int s6dns_message_parse_question (s6dns_domain_t *name, uint16_t *qtype, char const *packet, unsigned int packetlen, unsigned int *pos)
+int s6dns_message_parse_question (s6dns_message_counts_t *counts, s6dns_domain_t *name, uint16_t *qtype, char const *packet, unsigned int packetlen, unsigned int *pos)
{
uint16_t qclass ;
+ if (!counts->qd) return (errno = EINVAL, 0) ;
if (!s6dns_message_get_domain(name, packet, packetlen, pos)) return 0 ;
if (*pos + 4 > packetlen) return (errno = EPROTO, 0) ;
uint16_unpack_big(packet + *pos, qtype) ; *pos += 2 ;
uint16_unpack_big(packet + *pos, &qclass) ; *pos += 2 ;
if (qclass != S6DNS_C_IN) return (errno = ENOTSUP, 0) ;
+ counts->qd-- ;
return 1 ;
}