www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Chernov <a...@nagual.pp.ru>
Subject general/7495: Wrong cast used to obtain index from a char
Date Sat, 31 Mar 2001 19:47:19 GMT

>Number:         7495
>Category:       general
>Synopsis:       Wrong cast used to obtain index from a char
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Sat Mar 31 11:50:00 PST 2001
>Originator:     ache@nagual.pp.ru
>Release:        1.3.19
Any signed char C compiler.
This line from util.c

#define TEST_CHAR(c, f) (test_char_table[(unsigned)(c)] & (f))

use wrong cast which make index worse by another way: 8bit chars become too big (consider
0xFFFFFFFF from '\377' char) instead of negative. Proper cast
is (unsigned char) not just (unsigned)! 

Plain (unsigned) cast promote to int first, i.e. makes -1 from '\377' and then convert -1

Use (unsigned char) cast instead of just (unsigned)
 [In order for any reply to be added to the PR database, you need]
 [to include <apbugs@Apache.Org> in the Cc line and make sure the]
 [subject line starts with the report component and number, with ]
 [or without any 'Re:' prefixes (such as "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match this       ]
 [pattern, your message will be misfiled and ignored.  The       ]
 ["apbugs" address is not added to the Cc line of messages from  ]
 [the database automatically because of the potential for mail   ]
 [loops.  If you do not include this Cc, your reply may be ig-   ]
 [nored unless you are responding to an explicit request from a  ]
 [developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]

View raw message