*----------------------------------------------------------------
*/
+/*
+ * Per RFC 1413, space and tab are whitespace in ident messages.
+ */
+static bool
+is_ident_whitespace(const char c)
+{
+ return c == ' ' || c == '\t';
+}
+
/*
* Parse the string "*ident_response" as a response from a query to an Ident
* server. If it's a normal response indicating a user name, return true
int i; /* Index into *response_type */
cursor++; /* Go over colon */
- while (pg_isblank(*cursor))
+ while (is_ident_whitespace(*cursor))
cursor++; /* skip blanks */
i = 0;
- while (*cursor != ':' && *cursor != '\r' && !pg_isblank(*cursor) &&
+ while (*cursor != ':' && *cursor != '\r' && !is_ident_whitespace(*cursor) &&
i < (int) (sizeof(response_type) - 1))
response_type[i++] = *cursor++;
response_type[i] = '\0';
- while (pg_isblank(*cursor))
+ while (is_ident_whitespace(*cursor))
cursor++; /* skip blanks */
if (strcmp(response_type, "USERID") != 0)
return false;
else
{
cursor++; /* Go over colon */
- while (pg_isblank(*cursor))
+ while (is_ident_whitespace(*cursor))
cursor++; /* skip blanks */
/* Rest of line is user name. Copy it over. */
i = 0;
static void tokenize_error_callback(void *arg);
-/*
- * isblank() exists in the ISO C99 spec, but it's not very portable yet,
- * so provide our own version.
- */
-bool
+static bool
pg_isblank(const char c)
{
- return c == ' ' || c == '\t' || c == '\r';
+ /* don't accept non-ASCII data */
+ return (!IS_HIGHBIT_SET(c) && isblank(c));
}
bool case_insensitive);
extern HbaLine *parse_hba_line(TokenizedAuthLine *tok_line, int elevel);
extern IdentLine *parse_ident_line(TokenizedAuthLine *tok_line, int elevel);
-extern bool pg_isblank(const char c);
extern FILE *open_auth_file(const char *filename, int elevel, int depth,
char **err_msg);
extern void free_auth_file(FILE *file, int depth);