diff options
author | Michael McVady <femtonaut@gmail.com> | 2024-01-30 22:28:48 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2024-01-30 22:28:48 -0600 |
commit | 8c3184ae7d63b8ef2053c11b11e4bdc0e9f16c82 (patch) | |
tree | 448dfd38e8810a034790b4b89279b9e446269555 /src/clog.c | |
parent | 9bdfca2712807729b0b4ebc977d1bcd9599d2ea2 (diff) |
Check for end of UUID once
Diffstat (limited to 'src/clog.c')
-rw-r--r-- | src/clog.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -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)); |