| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,TW_RJ |
| X-Spam-Check-By: | sourceware.org |
| X-Yahoo-SMTP: | mjD.OBqswBAPbVUxYJaYPvc61jLEnpq8VnBwJGdbEJOPA9xw |
| Message-ID: | <4C36AC46.1040102@sbcglobal.net> |
| Date: | Fri, 09 Jul 2010 04:57:42 +0000 |
| From: | Greg Chicares <gchicares AT sbcglobal DOT net> |
| User-Agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: Interesting discovery in the C library that Cygwin uses |
| References: | <AANLkTimvCA12jm3SNDaDs7yckO9GLwPd01P_U7mCqYju AT mail DOT gmail DOT com> |
| In-Reply-To: | <AANLkTimvCA12jm3SNDaDs7yckO9GLwPd01P_U7mCqYju@mail.gmail.com> |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.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 |
On 2010-07-08 23:34Z, Gregg Levine wrote:
> I made this discovery whilst building the urjtag program from its SVN trunk:
> make[3]: Entering directory `/usr/local/urjtag/urjtag/trunk/urjtag/src/tap'
> CC tap.lo
> CC register.lo
> CC state.lo
> CC chain.lo
> CC detect.lo
> detect.c: In function `find_record':
> detect.c:89: warning: array subscript has type `char'
http://urjtag.svn.sourceforge.net/viewvc/urjtag/trunk/urjtag/src/tap/detect.c?annotate=1799
char *p;
...
while (*p && isspace (*p))
The problem is that 'char' can be signed, and a signed quantity can
be negative. But values passed to <ctype.h> functions like isspace()
have to be in the (nonnegative) range of an unsigned char (or be
equal to EOF); otherwise, the behavior is undefined. Consider using
unsigned char *p;
instead of
char *p;
in the example above.
Here's some discussion:
https://www.securecoding.cert.org/confluence/display/seccode/STR37-C.+Arguments+to+character+handling+functions+must+be+representable+as+an+unsigned+char
http://old.nabble.com/warnings-from-use-of-ctype.h-methods-td27865685.html
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |