From user-return-269-apmail-stdcxx-user-archive=stdcxx.apache.org@stdcxx.apache.org Fri Sep 05 12:18:30 2008 Return-Path: Delivered-To: apmail-stdcxx-user-archive@www.apache.org Received: (qmail 74563 invoked from network); 5 Sep 2008 12:18:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Sep 2008 12:18:30 -0000 Received: (qmail 63533 invoked by uid 500); 5 Sep 2008 12:18:19 -0000 Delivered-To: apmail-stdcxx-user-archive@stdcxx.apache.org Received: (qmail 63517 invoked by uid 500); 5 Sep 2008 12:18:19 -0000 Mailing-List: contact user-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@stdcxx.apache.org Delivered-To: mailing list user@stdcxx.apache.org Received: (qmail 63506 invoked by uid 99); 5 Sep 2008 12:18:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Sep 2008 05:18:19 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [203.16.214.72] (HELO mail.internode.on.net) (203.16.214.72) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Sep 2008 12:17:20 +0000 Received: from goanna (unverified [121.44.14.71]) by mail.internode.on.net (SurgeMail 3.8f2) with ESMTP id 27570569-1927428 for multiple; Fri, 05 Sep 2008 21:47:52 +0930 (CST) Date: Fri, 5 Sep 2008 22:16:48 +1000 From: Mark Wright To: user@stdcxx.apache.org Cc: msebor@gmail.com Subject: Re: std::collate delete [] non heap memory Message-ID: <20080905221648.00006553@goanna> In-Reply-To: <20080905212709.0000392d@goanna> References: <20080905004815.00002dd7@goanna> <48C068B2.70207@gmail.com> <20080905212709.0000392d@goanna> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.10.11; i386-pc-solaris2.10) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org > On Fri, 5 Sep 2008 21:27:09 +1000 > Mark Wright wrote: > > Anyway I was wondering if it might help to make the > just_in_case_buf buffer large to try to work around Solaris 10's > strxfrm() insanity? The trouble with that idea though is the concern that strxfrm() on Solaris 10u5 may still overwrite past the end of the buffer no matter how large I made just_in_case_buf. So I instead propose this fix: goanna% diff -wc stdcxx-4.2.1/src/orig/collate.cpp stdcxx-4.2.1/src/collate.cpp *** stdcxx-4.2.1/src/orig/collate.cpp 2008-04-25 10:25:19.000000000 +1000 --- stdcxx-4.2.1/src/collate.cpp 2008-09-05 22:00:05.074726012 +1000 *************** *** 522,531 **** --- 522,537 ---- src += (last - src) + 1; } + #if defined(__sun) && defined(__SVR4) + // Solaris 10u5 overwrites memory past the end of + // just_in_case_buf[8], to avoid this, pass a 0 pointer + char *just_in_case_buf = (char *)0; + #else // provide a destination buffer to strxfrm() in case // it's buggy (such as MSVC's) and tries to write to // the buffer even if it's 0 char just_in_case_buf [8]; + #endif const _RWSTD_SIZE_T dst_size = strxfrm (just_in_case_buf, psrc, 0); // check for strxfrm() errors goanna% I tested this with my test program on Solaris 10u5 with Sun Studio 12 C++, it works fine. Thanks very much, Mark --