Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 52437 invoked from network); 8 Oct 2007 22:20:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Oct 2007 22:20:49 -0000 Received: (qmail 95993 invoked by uid 500); 8 Oct 2007 22:20:37 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 95978 invoked by uid 500); 8 Oct 2007 22:20:37 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 95965 invoked by uid 99); 8 Oct 2007 22:20:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 15:20:37 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 22:20:41 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id D356571422B for ; Mon, 8 Oct 2007 15:19:50 -0700 (PDT) Message-ID: <9791773.1191881990863.JavaMail.jira@brutus> Date: Mon, 8 Oct 2007 15:19:50 -0700 (PDT) From: "Travis Vitek (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Updated: (STDCXX-581) purify reports uninitialized memory read in __rw_memattr In-Reply-To: <14759904.1191879950689.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-581?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Travis Vitek updated STDCXX-581: -------------------------------- Attachment: stdcxx-581.patch > purify reports uninitialized memory read in __rw_memattr > -------------------------------------------------------- > > Key: STDCXX-581 > URL: https://issues.apache.org/jira/browse/STDCXX-581 > Project: C++ Standard Library > Issue Type: Improvement > Components: Test Driver > Reporter: Travis Vitek > Assignee: Travis Vitek > Fix For: 4.2.1 > > Attachments: 0.char.log, stdcxx-581.patch > > > __rw_memattr() checks that a specified block of memory is addressable for reading or writing. It takes a pointer and a length. If the length is _RWSTD_SIZE_MAX, then it is assumed that the pointer refers to a null terminated string and the number of bytes is counted via a call to memchr() or strchr(). Unfortunately, sof the formatted io functions in printf.cpp cause __rw_memattr() to unnecessarily touch uninitialized memory or even worse to look for the null terminator in a buffer that is not null terminated. > An example of this is _rw_fmtlong(). It allocates a buffer of 130 chars and formats a long value into that buffer without null terminating the buffer [it appears that this is intentional]. It then calls _rw_fmtstr() on the result. Internally _rw_fmtstr() calls __rw_memattr() with _RWSTD_SIZE_MAX as the number of bytes to verify read/write access to. Because the buffer is not null terminated, the __rw_memattr() call could walk past the end of the array looking for a null terminator. > I believe that the call to __rw_memattr() in _rw_fmtlong() should be getting the actual length of the string that is being formatted so as to avoid reading past the end of the source array. I see no reason to allow __rw_memattr() to go looking for a null terminator when we don't know that there is one there. This same problem occurs in _rw_fmtwstr() and _rw_fmtarray(). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.