[FFmpeg-devel] [RFC] libavformat: URL reassembly with IPv6 addresses
Ronald S. Bultje
rsbultje
Fri Feb 26 18:57:26 CET 2010
Hi,
On Fri, Feb 26, 2010 at 12:49 PM, Martin Storsj? <martin at martin.st> wrote:
> 3) Add a separate function for appending a properly escaped hostname to a
> URL. This feels the cleanest to me, but requires a bit more changes to all
> the current occurrances of snprintf assembly of URLs, splitting out the
> "append the hostname" part from each case. The function could look
> something like this:
>
> void url_host_cat(char *str, int size, const char *hostname)
> {
> ? ?if (strchr(hostname, ':')) {
You can use getaddrinfo() with a flag of NUMERICONLY and then check
the return value's address type here. This is only defined for IPv6
addresses, not for anything else crazy like people adding random input
into this function. In fact, we should error out here.
> ? ? ? ?av_strlcat(str, "[", size);
> ? ? ? ?av_strlcat(str, hostname, size);
> ? ? ? ?av_strlcat(str, "]", size);
> ? ?} else {
> ? ? ? ?av_strlcat(str, hostname, size);
> ? ?}
> }
I'd favour this, and then use it only in places where it matters.
Oh, and yes, I fixed url_split() for this years ago, and then tried
gradually adding IPv6 support into FFmpeg and failed miserably, so
thanks again for taking over successfully. :-).
Ronald
More information about the ffmpeg-devel
mailing list