delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/01/27/07:35:18

X-Recipient: archive-cygwin AT delorie DOT 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 AT cygwin DOT com>
Subject: Re: src/winsup/cygwin ChangeLog dcrt0.cc
X-PHP-Originating-Script: 0:main.inc
MIME-Version: 1.0
Date: Fri, 27 Jan 2012 12:19:44 +0000
From: Chris January <chris AT atomice DOT net>
In-Reply-To: <25fbed8bb03f1d4ebf8de99b8be8bfbf@shell.sh.cvut.cz>
References: <25fbed8bb03f1d4ebf8de99b8be8bfbf AT shell DOT sh DOT cvut DOT cz>
Message-ID: <fc9e00f844db0a4e95a6538bc33f730f@127.0.0.1>
X-Sender: chris AT atomice DOT net
User-Agent: Roundcube Webmail/0.6
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019