Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 39434 invoked from network); 7 Jul 2006 02:29:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2006 02:29:30 -0000 Received: (qmail 55098 invoked by uid 500); 7 Jul 2006 02:29:29 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 54680 invoked by uid 500); 7 Jul 2006 02:29:27 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 54669 invoked by uid 99); 7 Jul 2006 02:29:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 19:29:27 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of xiaofeng.li@gmail.com designates 66.249.92.169 as permitted sender) Received: from [66.249.92.169] (HELO ug-out-1314.google.com) (66.249.92.169) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 19:29:25 -0700 Received: by ug-out-1314.google.com with SMTP id q2so2477155uge for ; Thu, 06 Jul 2006 19:29:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=E1Yw/7X6XNqT8wFo/DISHRU3hRShuekr83123BTQaOgoY4rcMuBA8WbNSSYAG1jfhEW1Fn4ZDAUU9A84IpTN6x+DNxKn2htvdDuhuLmmn2Lk3TUHKs7tIJDLHkhf9716KAMqq8lR3tWttFJqoxaWAz2qYTf54yTK4Y9CD3aSBus= Received: by 10.66.243.2 with SMTP id q2mr1455954ugh; Thu, 06 Jul 2006 19:29:04 -0700 (PDT) Received: by 10.67.32.16 with HTTP; Thu, 6 Jul 2006 19:28:59 -0700 (PDT) Message-ID: <9623c9a50607061928q2876a9d0s8022bb4929453ffe@mail.gmail.com> Date: Fri, 7 Jul 2006 10:28:59 +0800 From: "Xiao-Feng Li" To: harmony-dev@incubator.apache.org Subject: Re: Strategy for Harmony to work with Visual Studio 2005? In-Reply-To: <200607062152.38599.gshimansky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9623c9a50607051954h64d685e0v2817e333afd05bc5@mail.gmail.com> <44ACE25F.5070802@pobox.com> <9623c9a50607060335y469a0b11q380bf25f6f95c737@mail.gmail.com> <200607062152.38599.gshimansky@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I would suggest another approach. Since the safe CRT APIs are mostly similar to the original counterpart but enforcing safety checks and validations, we can take them as coding conventions, so as to achieve both the safety and portability. For example, with strcpy, we do this way: step 1. write a safe version strcpy_s on platforms that have no safe CRT support, see below. step 2. replace all strcpy(dst, src) invocations with strcpy_s(dst, count, src); This version of strcpy_s is only for illustration purpose and follow the standard safety checkings. #define MAX_STR_LEN (1<<30) #ifndef SAFE_CRT int strcpy_s(dst, count, src) { if( dst != null && count > 0 && count <= MAX_STR_LEN ) dst[0] = '\0'; if( dst == NULL || src == NULL ) return -1; if( count == 0 || count > MAX_STR_LEN ) return -1; if( count <= strlen(src) ) return -1; //strlen should use safer version if( mem_overlap (dst, src) ) return -1; strcpy(dst, src); return 0; } #endif Thanks, xiaofeng On 7/7/06, Gregory Shimansky wrote: > On Thursday 06 July 2006 14:35 Xiao-Feng Li wrote: > > Ok, then I will get back to VC7 at the moment. :-) Let's wait till > > its acceptance by the community. > > > > Actually I don't see them as new APIs; instead, I view them as > > enforced good coding conventions that help to achieve better security, > > e.g., always check the buffer size in debug mode. (Personally I like > > the changes immediately when I met them. My only question was why we > > didn't do that earlier. :-) > > If they were just drop in replacements of the old functions this could be done > quickly. But they are not compatible for the most part and so may complicate > the code significantly to support both old (e.g. VC7 and older, cyginw/mingw > targets) and new version. > > You can use includes from Platform SDK which has headers compatible with old > API [1] unless MS has changed new versions of Platform SDK to have this > secure stuff and no alternative since I wrote that email. > > > On 7/6/06, Geir Magnusson Jr wrote: > > > I think the key reason is that this is non-standard stuff from > > > microsoft's for-fee toolchain, and people in OSS try to avoid having a > > > dependency on that. > > > > > > I wouldn't mind supporting this at some point a) once it becomes a > > > standard and b) has broad acceptance, but I'm guessing that's going to > > > take years. > > > > > > People who have used the free version of MSFT tools seem to just set the > > > flag as you note. > > There are two flags. I've found the second in [2]. But I didn't try to use the > because I used Platform SDK includes workaround. Maybe defining them is still > not enough. > > [1] > http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200606.mbox/<208da7a50606011434i405b7d5ao4be8a9fefc52e183%40mail.gmail.com> > > [2] > http://www.wxwidgets.org/wiki/index.php/MSVC_.NET_Setup_Guide#Version_Specific_Comments_.26_Instructions > > -- > Gregory Shimansky, Intel Middleware Products Division > > --------------------------------------------------------------------- > Terms of use : http://incubator.apache.org/harmony/mailing.html > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org > For additional commands, e-mail: harmony-dev-help@incubator.apache.org > > --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org