diff options
Diffstat (limited to 'src')
-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)); |