X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-0.0 required=5.0	tests=BAYES_20,RCVD_IN_DNSWL_NONE
X-Spam-Check-By: sourceware.org
To: <cygwin@cygwin.com>
Subject: Re: src/winsup/cygwin ChangeLog dcrt0.cc
X-PHP-Originating-Script: 0:main.inc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Date: Fri, 27 Jan 2012 12:19:44 +0000
From: Chris January <chris@atomice.net>
In-Reply-To: <25fbed8bb03f1d4ebf8de99b8be8bfbf@shell.sh.cvut.cz>
References: <25fbed8bb03f1d4ebf8de99b8be8bfbf@shell.sh.cvut.cz>
Message-ID: <fc9e00f844db0a4e95a6538bc33f730f@127.0.0.1>
X-Sender: chris@atomice.net
User-Agent: Roundcube Webmail/0.6
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q0RCZE1l001427

On 27.01.2012 10:46, Václav Zeman wrote:
>> +#define is_dos_path(s) (isdrive(s) \
>> +			|| ((s)[0] == '\\' \
>> +			    && (s)[1] == '\\' \
>> +			    && isalpha ((s)[2]) \
>> +			    && strchr ((s) + 3, '\\')))
> Is it safe to access 2nd, 3rd and 4th characters of the word without
> checking the length first?

Yes, if s is a NUL-terminated string. If s[0] != '\0' (because, e.g., 
s[0] == '\\') then s[1] is valid; if s[1] != '\0' then s[2] is valid, 
and so on.

Chris


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


