mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Solaris CC freaks out if isspace and friends get anything other than an int. We learned that, so we casted. But it is also a bad idea to cast a signed char to an int and expect things to work on win32. Now we cast to unsigned char, then to int, then pass to isspace. Ug
svn:r3120
This commit is contained in:
parent
d7dbfd3644
commit
fe6eb34a10
@ -82,6 +82,10 @@ int tor_snprintf(char *str, size_t size, const char *format, ...)
|
|||||||
CHECK_PRINTF(3,4);
|
CHECK_PRINTF(3,4);
|
||||||
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
|
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
|
||||||
|
|
||||||
|
#define TOR_ISSPACE(c) isspace((int)(unsigned char)(c))
|
||||||
|
#define TOR_ISXDIGIT(c) isxdigit((int)(unsigned char)(c))
|
||||||
|
#define TOR_ISDIGIT(c) isdigit((int)(unsigned char)(c))
|
||||||
|
|
||||||
/* ===== Time compatibility */
|
/* ===== Time compatibility */
|
||||||
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
||||||
struct timeval {
|
struct timeval {
|
||||||
|
@ -262,7 +262,7 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
|
|||||||
cp = str;
|
cp = str;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (flags&SPLIT_SKIP_SPACE) {
|
if (flags&SPLIT_SKIP_SPACE) {
|
||||||
while (isspace((int)*cp)) ++cp;
|
while (TOR_ISSPACE(*cp)) ++cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max>0 && n == max-1) {
|
if (max>0 && n == max-1) {
|
||||||
@ -279,7 +279,7 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags&SPLIT_SKIP_SPACE) {
|
if (flags&SPLIT_SKIP_SPACE) {
|
||||||
while (end > cp && isspace((int)*(end-1)))
|
while (end > cp && TOR_ISSPACE(*(end-1)))
|
||||||
--end;
|
--end;
|
||||||
}
|
}
|
||||||
if (end != cp || !(flags&SPLIT_IGNORE_BLANK)) {
|
if (end != cp || !(flags&SPLIT_IGNORE_BLANK)) {
|
||||||
|
@ -974,11 +974,12 @@ int
|
|||||||
crypto_pk_check_fingerprint_syntax(const char *s)
|
crypto_pk_check_fingerprint_syntax(const char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
const unsigned char *cp = s;
|
||||||
for (i = 0; i < FINGERPRINT_LEN; ++i) {
|
for (i = 0; i < FINGERPRINT_LEN; ++i) {
|
||||||
if ((i%5) == 4) {
|
if ((i%5) == 4) {
|
||||||
if (!isspace((int)s[i])) return 0;
|
if (!TOR_ISSPACE(cp[i])) return 0;
|
||||||
} else {
|
} else {
|
||||||
if (!isxdigit((int)s[i])) return 0;
|
if (!TOR_ISXDIGIT(cp[i])) return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s[FINGERPRINT_LEN]) return 0;
|
if (s[FINGERPRINT_LEN]) return 0;
|
||||||
|
@ -331,8 +331,8 @@ int strcasecmpend(const char *s1, const char *s2)
|
|||||||
const char *eat_whitespace(const char *s) {
|
const char *eat_whitespace(const char *s) {
|
||||||
tor_assert(s);
|
tor_assert(s);
|
||||||
|
|
||||||
while (isspace((int)*s) || *s == '#') {
|
while (TOR_ISSPACE(*s) || *s == '#') {
|
||||||
while (isspace((int)*s))
|
while (TOR_ISSPACE(*s))
|
||||||
s++;
|
s++;
|
||||||
if (*s == '#') { /* read to a \n or \0 */
|
if (*s == '#') { /* read to a \n or \0 */
|
||||||
while (*s && *s != '\n')
|
while (*s && *s != '\n')
|
||||||
@ -358,7 +358,7 @@ const char *eat_whitespace_no_nl(const char *s) {
|
|||||||
const char *find_whitespace(const char *s) {
|
const char *find_whitespace(const char *s) {
|
||||||
tor_assert(s);
|
tor_assert(s);
|
||||||
|
|
||||||
while (*s && !isspace((int)*s) && *s != '#')
|
while (*s && !TOR_ISSPACE(*s) && *s != '#')
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -427,8 +427,8 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
|
|||||||
tor_assert(base <= 10);
|
tor_assert(base <= 10);
|
||||||
r = (uint64_t)_atoi64(s);
|
r = (uint64_t)_atoi64(s);
|
||||||
endptr = (char*)s;
|
endptr = (char*)s;
|
||||||
while (isspace(*endptr)) endptr++;
|
while (TOR_ISSPACE(*endptr)) endptr++;
|
||||||
while (isdigit(*endptr)) endptr++;
|
while (TOR_ISDIGIT(*endptr)) endptr++;
|
||||||
#else
|
#else
|
||||||
r = (uint64_t)_strtoui64(s, &endptr, base);
|
r = (uint64_t)_strtoui64(s, &endptr, base);
|
||||||
#endif
|
#endif
|
||||||
@ -936,7 +936,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
|
|||||||
*key_out = *value_out = key = val = NULL;
|
*key_out = *value_out = key = val = NULL;
|
||||||
/* Skip until the first keyword. */
|
/* Skip until the first keyword. */
|
||||||
while (1) {
|
while (1) {
|
||||||
while (isspace(*line))
|
while (TOR_ISSPACE(*line))
|
||||||
++line;
|
++line;
|
||||||
if (*line == '#') {
|
if (*line == '#') {
|
||||||
while (*line && *line != '\n')
|
while (*line && *line != '\n')
|
||||||
@ -953,7 +953,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
|
|||||||
|
|
||||||
/* Skip until the next space. */
|
/* Skip until the next space. */
|
||||||
key = line;
|
key = line;
|
||||||
while (*line && !isspace(*line) && *line != '#')
|
while (*line && !TOR_ISSPACE(*line) && *line != '#')
|
||||||
++line;
|
++line;
|
||||||
|
|
||||||
/* Skip until the value */
|
/* Skip until the value */
|
||||||
@ -969,7 +969,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
|
|||||||
else {
|
else {
|
||||||
cp = line-1;
|
cp = line-1;
|
||||||
}
|
}
|
||||||
while (cp>=val && isspace(*cp))
|
while (cp>=val && TOR_ISSPACE(*cp))
|
||||||
*cp-- = '\0';
|
*cp-- = '\0';
|
||||||
|
|
||||||
if (*line == '#') {
|
if (*line == '#') {
|
||||||
|
@ -2348,7 +2348,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok)
|
|||||||
*ok = 1;
|
*ok = 1;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
while (isspace(*cp))
|
while (TOR_ISSPACE(*cp))
|
||||||
++cp;
|
++cp;
|
||||||
for ( ;u->unit;++u) {
|
for ( ;u->unit;++u) {
|
||||||
if (!strcasecmp(u->unit, cp)) {
|
if (!strcasecmp(u->unit, cp)) {
|
||||||
|
@ -472,7 +472,7 @@ parse_http_response(const char *headers, int *code, time_t *date,
|
|||||||
tor_assert(headers);
|
tor_assert(headers);
|
||||||
tor_assert(code);
|
tor_assert(code);
|
||||||
|
|
||||||
while (isspace((int)*headers)) headers++; /* tolerate leading whitespace */
|
while (TOR_ISSPACE(*headers)) headers++; /* tolerate leading whitespace */
|
||||||
|
|
||||||
if (sscanf(headers, "HTTP/1.%d %d", &n1, &n2) < 2 ||
|
if (sscanf(headers, "HTTP/1.%d %d", &n1, &n2) < 2 ||
|
||||||
(n1 != 0 && n1 != 1) ||
|
(n1 != 0 && n1 != 1) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user