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

David Herrmann dh.herrmann at gmail.com
Thu Nov 27 07:12:20 PST 2014


Hi

On Tue, Nov 18, 2014 at 4:52 AM, 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.

Your patch fixes the issue, indeed. However, I didn't have the time to
look this up in the DNS RFC. I'm not really sure TXT records cannot be
empty (and I'm not sure any follow-up RFC allows empty records).
Therefore, I fixed resolved to work with empty txt.strings strvs
instead. See:

commit 0f84a72e3c0f58d71cff2121e6df1611eaf9c9ea
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Thu Nov 27 16:08:46 2014 +0100

    resolve: fix NULL deref on strv comparison


Thanks!
David

> ---
>  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) {
>                          r = dns_packet_read_string(p, &s, NULL);
>                          if (r < 0)
> --
> 2.1.2
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list