From owner-svn-src-all@FreeBSD.ORG Mon May 5 23:21:58 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1B06E45D for ; Mon, 5 May 2014 23:21:58 +0000 (UTC) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) (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 8C500112 for ; Mon, 5 May 2014 23:21:56 +0000 (UTC) Received: by mail-lb0-f179.google.com with SMTP id c11so3731947lbj.24 for ; Mon, 05 May 2014 16:21:54 -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=RdJTj/0F5GblmpcnQQsahhxkhR2bT+QGtrQUJNq3gLmZSqwxktUlr6kfX24lcnLERC 1uoWS//Q/rIhxw5VVgQuxRL6Lzwv9K1uRUibb+vuwtX0wg7RZmpLQG1zUI/dpsfQtLLU y1IChMIrJGGLxICJB/Mlwdv53v2oYJYZRzopMZJbm8woQ5vRTJEsF7+mx2LDPlLBhhf/ Q+JAlmB0kwgiD+U1/Z8voSoIkRYNg5Nj2HzihDDp/doUNM77kDXqTiQqnHw5pnDY6KhZ S/FyMBwjCGgT9CdhAsmN64Ny3IJxOhgrudOD7mIBWg8sz2AfLmxDxldMCP/DU7+tZFp5 Ha6w== X-Gm-Message-State: ALoCoQnhxR2rPLexC50kReoyT+/tG2EYklir8e4wTEXVMqMmiWYIrYyVx7T5Zwh8TxpxGsl8yKo5 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-all@freebsd.org X-Mailman-Version: 2.1.18 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: Mon, 05 May 2014 23:21:58 -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--