mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix handling of zero length domain names in dn_expand
Date: Fri, 5 Sep 2014 00:15:52 +0200	[thread overview]
Message-ID: <20140904221551.GH10361@port70.net> (raw)
In-Reply-To: <20140904202053.GD23797@brightrain.aerifal.cx>

* Rich Felker <dalias@libc.org> [2014-09-04 16:20:53 -0400]:
> >  	char *dend = dest + (space > 254 ? 254 : space);
> > -	int len = -1, i, j;
> > -	if (p==end || !*p) return -1;
> > +	int len = -1, i, j, first = 1;
> > +	if (p==end || dest==dend) return -1;
> 
> Note that this does nothing to handle negative space, whereas ncopa's

i assumed it to be ub

> such. Semantically it seems to be a zero-length component at the end
> (corresponding to "example.com.." rather than "example.com.", in the
> notation where final dots are not elided). Understanding whether it's
> legal or not probably requires some language-lawyering with RFC 1035,

the rfc is not very clear but i think this case should work

a name is a sequence of labels terminated by a 0 length label

a compressed name is a leading sequence of labels terminated
by a pointer that can be expanded to a name

if 'sequence of labels' can be empty and the conversion to
dotted string notation is done after concatenating the
leading and trailing sequence then there is no '..' issue

> -	char *dend = dest + (space > 254 ? 254 : space);
> +	char *dend;
>  	int len = -1, i, j;
> -	if (p==end || !*p) return -1;
> +	if (p==end || size <= 0) return -1;
> +	dend = dest + (space > 254 ? 254 : space);

ok this part is better than mine


  reply	other threads:[~2014-09-04 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13  8:21 Natanael Copa
     [not found] ` <20140904095039.496f5810@ncopa-desktop.alpinelinux.org>
2014-09-04 17:07   ` Szabolcs Nagy
2014-09-04 18:11     ` Szabolcs Nagy
2014-09-04 20:20       ` Rich Felker
2014-09-04 22:15         ` Szabolcs Nagy [this message]
2014-09-04 22:41           ` Rich Felker
2014-09-04 20:22       ` Natanael Copa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140904221551.GH10361@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).