From b6235374b91ba7acf62c06c72de2f1291f46ac4c Mon Sep 17 00:00:00 2001 From: Chip Black Date: Mon, 17 Jan 2011 03:31:51 -0600 Subject: [PATCH] Restrict usernames to the same character set as tags --- database/database.h | 3 +++ database/tags.c | 5 ++--- database/util.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/database/database.h b/database/database.h index 4c5853e..2f71bee 100644 --- a/database/database.h +++ b/database/database.h @@ -7,6 +7,9 @@ #include #include +#define VALID_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_') +#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r') + struct record { uint32_t offset; uint16_t length; diff --git a/database/tags.c b/database/tags.c index a28df02..51d8698 100644 --- a/database/tags.c +++ b/database/tags.c @@ -12,10 +12,9 @@ #include #include "tags.h" #include "util.h" +#include "database.h" #include "config.h" -#define TAG_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_') -#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r') int tag_scan(const char *author, const char *data, int len, uint64_t record) { char *taglist[MAX_TAGS_PER_RECORD]; @@ -32,7 +31,7 @@ tag_scan_start: } int begin = i; int start = ++i; - while (i < len && TAG_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) { + while (i < len && VALID_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) { i++; } if (start - i == 0) continue; diff --git a/database/util.c b/database/util.c index 2accd5d..6a37e49 100644 --- a/database/util.c +++ b/database/util.c @@ -2,7 +2,7 @@ * BSD-style license. Please see the COPYING file for details. */ -#define VALID_CHAR(x) (x == ' ' || x == '\'' || x == '-' || x == '.' || (x >= '0' && x <= '9') || (x >= 'A' && x <= 'Z') || x == '_' || (x >= 'a' && x <= 'z')) +#include "database.h" int valid_name(const char *name) { int i; -- 2.25.1