[systemd-devel] [PATCH] Stop crashing on empty TXT

Lennart Poettering lennart at poettering.net
Sun Nov 30 18:12:47 PST 2014


On Tue, 18.11.14 14:52, Stanisław Pitucha (viraptor at gmail.com) wrote:

> TXT records should have at least one character, so enforce this.
> Previously parser SIGSEGV'd on ->txt.strings being NULL.
> ---
>  src/resolve/resolved-dns-packet.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
> index e5d07b3..b02b9dd 100644
> --- a/src/resolve/resolved-dns-packet.c
> +++ b/src/resolve/resolved-dns-packet.c
> @@ -1109,6 +1109,10 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
>          case DNS_TYPE_TXT: {
>                  char *s;
>  
> +                if (!rdlength) {
> +                        r = -EBADMSG;
> +                        goto fail;
> +                }
>                  while (p->rindex < offset + rdlength) {

RFC 6763, section 6.1 makes more elaborate suggestions how to encode
zero-length TXT arrays and how to decode zero-length TXT RRs. Strictly
speaking they are only suggestions for mDNS, but I figure they make
sense in the non-mDNS case too, and are generally better than just
generating a parse failure, hence I changed the code now to implement
them.

Thanks for the patch,

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list