summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-packet.c
diff options
context:
space:
mode:
authorStanisław Pitucha <viraptor@gmail.com>2014-11-18 14:52:13 +1100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-27 11:07:43 -0500
commit0e3434aeb1eed951fdbeddacc6126e10d82a1c8b (patch)
treeb457f055867114e2b2b4eb4fe919a28adacfd4a4 /src/resolve/resolved-dns-packet.c
parent59aa582137cab11ff6aeb9adc56b9e70c4d320ae (diff)
resolve: reject empty TXT records
TXT records should have at least one character, so enforce this. Before 0f84a72 parser SIGSEGV'd on ->txt.strings being NULL, but even if this is fixed we should reject invalid TXT records.
Diffstat (limited to 'src/resolve/resolved-dns-packet.c')
-rw-r--r--src/resolve/resolved-dns-packet.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index c587a56124..a9bd8b1398 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -1114,6 +1114,13 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
case DNS_TYPE_TXT: {
char *s;
+ /* RFC 1035 says that TXT must be at least one
+ string. Reject empty records. */
+ if (!rdlength) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
while (p->rindex < offset + rdlength) {
r = dns_packet_read_string(p, &s, NULL);
if (r < 0)