From stdcxx-dev-return-2238-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Thu Oct 05 15:58:59 2006 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 28723 invoked from network); 5 Oct 2006 15:58:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Oct 2006 15:58:59 -0000 Received: (qmail 38221 invoked by uid 500); 5 Oct 2006 15:58:59 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 38208 invoked by uid 500); 5 Oct 2006 15:58:58 -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 38197 invoked by uid 99); 5 Oct 2006 15:58:58 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Oct 2006 08:58:58 -0700 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= Received: from [208.30.140.160] ([208.30.140.160:19939] helo=moroha.quovadx.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id B7/51-04543-EBB25254 for ; Thu, 05 Oct 2006 08:58:56 -0700 Received: from qxvcexch01.ad.quovadx.com (qxvcexch01.ad.quovadx.com [192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id k95FwU0I032689 for ; Thu, 5 Oct 2006 15:58:30 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 5 Oct 2006 09:59:00 -0600 Message-ID: <45252BCB.9070708@roguewave.com> Date: Thu, 05 Oct 2006 09:59:07 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060417 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] STDCXX-93 References: <45250BCD.2060707@kyiv.vdiweb.com> In-Reply-To: <45250BCD.2060707@kyiv.vdiweb.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Oct 2006 15:59:01.0000 (UTC) FILETIME=[2C71D080:01C6E897] X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Farid Zaripov wrote: > Attached is a patch for resolve issue STDCXX-93. [...] > Index: time_put.cpp > =================================================================== > --- time_put.cpp (revision 453153) > +++ time_put.cpp (working copy) > @@ -725,8 +725,12 @@ > const char *str = > _RWSTD_STATIC_CAST (const char*, pun->abday (t.tm_wday, 0)); > > + _RWSTD_ASSERT (0 != str); > + > + _RWSTD_SIZE_T size = 1 + strlen (str); > + > wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off); > - _RWSTD_SIZE_T size = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX); > + size = mbstowcs (pwbuf, str, size); I don't think this is quite correct (even if it's safe). The last argument to mbstowcs() is the maximum number of elements in the destination buffer that the function can write. The length of the second argument (in bytes) might be greater than the number of multibyte characters in the string, which in turn might be even greater than the number of wide characters that correspond to it. We should either pass in the size of the destination buffer or some large value that windows can deal with. Martin