diff --git a/src/builtin.c b/src/builtin.c index 72357a9fc9..a5d59fbfa6 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1282,7 +1282,12 @@ static jv f_strptime(jq_state *jq, jv a, jv b) { const char *fmt = jv_string_value(b); const char *end = strptime(input, fmt, &tm); - if (end == NULL || (*end != '\0' && !isspace(*end))) { + /* + * "*end" may be a signed char, and passing a value which is less than -1 + * to isspace() violates the C standard, thus, casting to (unsigned char *) + * is necessary. + */ + if (end == NULL || (*end != '\0' && !isspace(*(unsigned char *)end))) { jv e = jv_invalid_with_msg(jv_string_fmt("date \"%s\" does not match format \"%s\"", input, fmt)); jv_free(a); jv_free(b); diff --git a/src/main.c b/src/main.c index a7f50b5135..74ecb08a38 100644 --- a/src/main.c +++ b/src/main.c @@ -102,8 +102,13 @@ static void die() { +/* + * "text[1]" may be a signed char, and passing a value which is less than -1 + * to isalpha() violates the C standard, thus, casting to (unsigned char *) + * is necessary. + */ static int isoptish(const char* text) { - return text[0] == '-' && (text[1] == '-' || isalpha(text[1])); + return text[0] == '-' && (text[1] == '-' || isalpha(((const unsigned char *)text)[1])); } static int isoption(const char* text, char shortopt, const char* longopt, size_t *short_opts) {