Avoid typecasting a signed char to an int when using is*() functions, as that
could very well cause a negate number get passed in and thus cause reading outside of the array usually used for this purpose. We avoid this by using the uppercase macro versions introduced just now that does some extra crazy typecasts to avoid byte codes > 127 to cause negative int values.
This commit is contained in:
10
lib/setup.h
10
lib/setup.h
@@ -348,6 +348,16 @@ int fileno( FILE *stream);
|
||||
#define DEBUGF(x)
|
||||
#endif
|
||||
|
||||
#ifndef ISSPACE
|
||||
/* typecasting craze to avoid negative number inputs to these macros */
|
||||
#define ISSPACE(x) (isspace((int)((unsigned char)x)))
|
||||
#define ISDIGIT(x) (isdigit((int)((unsigned char)x)))
|
||||
#define ISALNUM(x) (isalnum((int)((unsigned char)x)))
|
||||
#define ISXDIGIT(x) (isxdigit((int)((unsigned char)x)))
|
||||
#define ISGRAPH(x) (isgraph((int)((unsigned char)x)))
|
||||
#define ISALPHA(x) (isalpha((int)((unsigned char)x)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include macros and defines that should only be processed once.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user