Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Aug 2013 08:05:19 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Ulrich =?utf-8?B?U3DDtnJsZWlu?= <uqs@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Dag-Erling =?utf-8?B?U23Dg8W+cmdyYXY=?= <des@FreeBSD.org>
Subject:   Re: svn commit: r253680 - in head: lib/libfetch usr.bin/fetch
Message-ID:  <20130809074807.Q921@besplex.bde.org>
In-Reply-To: <20130808163451.GB54133@acme.spoerlein.net>
References:  <201307261553.r6QFrhwu084667@svn.freebsd.org> <20130808163451.GB54133@acme.spoerlein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1358863435-1375999519=:921
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 8 Aug 2013, Ulrich [utf-8] Sp=C3=B6rlein wrote:

> On Fri, 2013-07-26 at 15:53:43 +0000, Dag-Erling Sm=C3=83=C5=BErgrav wrot=
e:
>> Modified: head/lib/libfetch/common.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>> --- head/lib/libfetch/common.c=09Fri Jul 26 14:43:38 2013=09(r253679)
>> +++ head/lib/libfetch/common.c=09Fri Jul 26 15:53:43 2013=09(r253680)
>> +static struct addrinfo *
>> +fetch_ssl_get_numeric_addrinfo(const char *hostname, size_t len)
>> +{
>> +=09struct addrinfo hints, *res;
>> +=09char *host;
>> +
>> +=09host =3D (char *)malloc(len + 1);
>> +=09memcpy(host, hostname, len);
>> +=09host[len] =3D '\0';
>> +=09memset(&hints, 0, sizeof(hints));
>> +=09hints.ai_family =3D PF_UNSPEC;
>> +=09hints.ai_socktype =3D SOCK_STREAM;
>> +=09hints.ai_protocol =3D 0;
>> +=09hints.ai_flags =3D AI_NUMERICHOST;
>> +=09/* port is not relevant for this purpose */
>> +=09getaddrinfo(host, "443", &hints, &res);
>
> We check the return value for getaddrinfo() 210 out of 217 times in our
> tree, please check it here too. Thanks! CID 1061016

We sometimes check the return value of malloc() too.  Though checking is
usually just a waste of space and time, libraries should do it.

Style bugs in the above include:
- 'hostname' shadows a global function name
- bogus cast of malloc().  Old code in this file doesn't cast malloc().
- we labouriously use a home made strdup() since the string length is an
   arg.  But len must be strlen(hostname) for the home made strdup() to
   work.
- hints.ai_protocol is initialized twice
- the comment is neither capitalized nor terminated with a ".".  Old
   code in this file has mixed style bugs in comments, and uses the same
   style bugs often but not always.

Bruce
--0-1358863435-1375999519=:921--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130809074807.Q921>