From owner-svn-src-all@FreeBSD.ORG Thu Aug 8 22:05:31 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C1668694; Thu, 8 Aug 2013 22:05:31 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 81BC126AE; Thu, 8 Aug 2013 22:05:31 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 9CDA8D424A0; Fri, 9 Aug 2013 08:05:20 +1000 (EST) Date: Fri, 9 Aug 2013 08:05:19 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ulrich =?utf-8?B?U3DDtnJsZWlu?= Subject: Re: svn commit: r253680 - in head: lib/libfetch usr.bin/fetch In-Reply-To: <20130808163451.GB54133@acme.spoerlein.net> Message-ID: <20130809074807.Q921@besplex.bde.org> References: <201307261553.r6QFrhwu084667@svn.freebsd.org> <20130808163451.GB54133@acme.spoerlein.net> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1358863435-1375999519=:921" X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=YYGEuWhf c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=uBt_qsxboB0A:10 a=JzwRw_2MAAAA:8 a=dwYhbVbWzrsA:10 a=nlC_4_pT8q9DhB4Ho9EA:9 a=cz2ZRIgtxKwA:10 a=wJWlkF7cXJYA:10 a=J0YgI1mdwjNwhYDITaEA:9 a=45ClL6m2LaAA:10 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Dag-Erling =?utf-8?B?U23Dg8W+cmdyYXY=?= X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2013 22:05:31 -0000 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--