svn commit: r308996 - head/lib/libfetch

Ngie Cooper (yaneurabeya) yaneurabeya at gmail.com
Sun Mar 12 04:46:19 UTC 2017


> On Nov 22, 2016, at 05:30, Dag-Erling Smørgrav <des at 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 <freebsd at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20170311/32e5cd82/attachment-0001.sig>


More information about the svn-src-head mailing list