> On Nov 22, 2016, at 05:30, Dag-Erling Smørgrav <d...@freebsd.org> wrote:
> 
> Author: des
> Date: Tue Nov 22 13:30:07 2016
> New Revision: 308996
> URL: https://svnweb.freebsd.org/changeset/base/308996
> 
> Log:
>  Refactor fetch_connect() and fetch_bind() to improve readability and avoid
>  repeating the same DNS lookups.
> 
>  MFC after:   3 weeks
> 
> Modified:
>  head/lib/libfetch/common.c
>  head/lib/libfetch/common.h
>  head/lib/libfetch/ftp.c
> 
> Modified: head/lib/libfetch/common.c
> ==============================================================================
> --- head/lib/libfetch/common.c        Tue Nov 22 13:24:57 2016        
> (r308995)
> +++ head/lib/libfetch/common.c        Tue Nov 22 13:30:07 2016        
> (r308996)
> @@ -1,5 +1,5 @@
> /*-
> - * Copyright (c) 1998-2014 Dag-Erling Smørgrav
> + * Copyright (c) 1998-2016 Dag-Erling Smørgrav
>  * Copyright (c) 2013 Michael Gmelin <free...@grem.de>
>  * All rights reserved.
>  *
> @@ -241,27 +241,83 @@ fetch_ref(conn_t *conn)
> 
> 
> /*
> + * Resolve an address
> + */
> +struct addrinfo *
> +fetch_resolve(const char *addr, int port, int af)
> +{
> +     char hbuf[256], sbuf[8];
> +     struct addrinfo hints, *res;
> +     const char *sep, *host, *service;
> +     int err, len;
> +
> +     /* split address if necessary */
> +     err = EAI_SYSTEM;
> +     if ((sep = strchr(addr, ':')) != NULL) {

Hi Bjoern,
        Shouldn’t this be strrchr instead of strchr since you’re scanning for 
the service from the right side of the host, e.g. “foo:service” or 
“[::1]:service”? This code would match index 3 in the first example, but it 
would match index 2 in the second example.
Thanks,
-Ngie

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to