From 8c3184ae7d63b8ef2053c11b11e4bdc0e9f16c82 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Tue, 30 Jan 2024 22:28:48 -0600 Subject: Check for end of UUID once --- src/clog.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/clog.c b/src/clog.c index c9aab60..507b425 100644 --- a/src/clog.c +++ b/src/clog.c @@ -23,8 +23,8 @@ KORE_SECCOMP_FILTER("clog", KORE_SYSCALL_ALLOW(uname) ) -#define STR_HELPER(s) #s #define STR(s) STR_HELPER(s) +#define STR_HELPER(s) #s #define MAX_ENTRIES 15 enum query_status { QUERY_STATUS_OK, QUERY_STATUS_ERROR, QUERY_STATUS_NOT_FOUND }; @@ -149,19 +149,15 @@ int validate_uuid(const char *uuid) { return KORE_RESULT_ERROR; } - for (i = 0; i <= 36; i++) { + for (i = 0; i < 36; i++) { if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) { if (uuid[i] != '-') return KORE_RESULT_ERROR; continue; } - if (i == 36) { - if (uuid[i] != '\0') - return KORE_RESULT_ERROR; - continue; - } - if (!isxdigit(uuid[i])) + if (!isxdigit(uuid[i])) { return KORE_RESULT_ERROR; + } } return KORE_RESULT_OK; @@ -529,7 +525,6 @@ int sql_select(struct entry_query *eq) { goto out; } - // Query for entries, check for error. if (eq->id) { // Query an entry. err = kore_pgsql_query_params(&sql, q_select_entry, @@ -568,10 +563,9 @@ int sql_select(struct entry_query *eq) { goto out; } - // Iterate over entries and render them. + // Fetch & copy data to entries eq->num_entries = kore_pgsql_ntuples(&sql); for (i = 0; i < eq->num_entries; i++) { - // Fetch & copy data to entry entry = kore_malloc(sizeof(struct entry)); entry->id = kore_strdup(kore_pgsql_getvalue(&sql, i, 0)); entry->title = kore_strdup(kore_pgsql_getvalue(&sql, i, 1)); -- cgit v1.2.3