From owner-svn-src-head@FreeBSD.ORG Mon May 5 23:15:46 2014 Return-Path: Delivered-To: svn-src-head@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 ESMTPS id 96C33325 for ; Mon, 5 May 2014 23:15:46 +0000 (UTC) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 151DC79 for ; Mon, 5 May 2014 23:15:45 +0000 (UTC) Received: by mail-lb0-f176.google.com with SMTP id p9so1485079lbv.21 for ; Mon, 05 May 2014 16:15:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=X6hT0e2HaTVu+txpBELzsMKsP4f5BgcHhauttU8oeHg=; b=cFGrdeEWXNANjNz+C/TpD4ZH40u6JPik/wEYORMaUpb7lja1gprH6iIy/fH2aNyCz+ 9aMVVV8pjYxIgfEEsHsqA1DCrlcMzhBxFPbPHOj57I0ZuoNwiPiYWO87ZFvfg+hj3LE4 TkT3MuJtYwdpEvK6oFgUj9pZv+j36RyJ3KqkLt1Z55gsUe+yIONv5M6rEGTCks1ijNTA xZuFMmRYcnTZTKWpOt7edivdddbL+iouK0/hBXJKo1nLf+s7PM8Rt0A++H6zGzew3A0D Qho5cRV2UuK7fg/uncVYMlcflAsLZwtZcwGxr/4zYT8gwrMu0LSxr6jscb91cnL2VvgW BdPQ== X-Gm-Message-State: ALoCoQlnVV3Ns+/mrfu4WCcpDZnCpy96iNoZfszJSnhHC9dmATjD7yxDecMuS3DBsLradlrA5RvU X-Received: by 10.112.12.103 with SMTP id x7mr3985345lbb.36.1399331743825; Mon, 05 May 2014 16:15:43 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id c6sm9598706laa.16.2014.05.05.16.15.42 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 16:15:42 -0700 (PDT) Message-ID: <53681B94.103@freebsd.org> Date: Tue, 06 May 2014 03:15:32 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Warner Losh , David Chisnall Subject: Re: svn commit: r265367 - head/lib/libc/regex References: <201405051641.s45GfFje086423@svn.freebsd.org> <5367CD77.40909@freebsd.org> <5367EB54.1080109@FreeBSD.org> <3C7CFFB7-5C84-4AC1-9A81-C718D184E87B@FreeBSD.org> <7D7A417E-17C3-4001-8E79-0B57636A70E1@gmail.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="QMWMFIo3uWxGbgQmFRojTiauNNW53EpuS" Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Pedro Giffuni , src-committers X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2014 23:15:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QMWMFIo3uWxGbgQmFRojTiauNNW53EpuS Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06.05.2014 2:59, Warner Losh wrote: > Stupid is as stupid does. malloc and realloc both have this same issue.= While an interesting theoretical attack, the size doesn=E2=80=99t necess= arily come from multiplication. Careful coding is still required, not mat= ter what spin you put on this. reallocf() solves the memory leak issue, b= ut not the problem with overflow (which the realloc() interface has too).= The caller can check to make sure they aren=E2=80=99t requesting too muc= h memory and overflowing. The interface isn=E2=80=99t designed to solve t= he problem you are complaining about. >=20 > There=E2=80=99s only so much you can do to prevent programming errors. = calloc() isn=E2=80=99t going to solve the world=E2=80=99s problems for yo= u, and introduces a non-trivial amount of overhead for the trivial amount= of overhead that is =E2=80=9Csaved=E2=80=9D by moving the overflow check= from the caller to the callee... I agree completely. --=20 http://ache.vniz.net/ --QMWMFIo3uWxGbgQmFRojTiauNNW53EpuS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlNoG54ACgkQVg5YK5ZEdN1NLQCgusr3bvds8O+SZFi9e3fwUEeB li0An2KrVfKXGSc4J/lIJWuraM4R0daW =RGRk -----END PGP SIGNATURE----- --QMWMFIo3uWxGbgQmFRojTiauNNW53EpuS--