This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: src/winsup/cygwin ChangeLog dcrt0.cc


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]