botched raw() calls no longer DOS

This commit is contained in:
anon 2023-08-03 15:49:45 +02:00
parent d158b9c863
commit add94130bd

View File

@ -21,13 +21,6 @@
} \ } \
} while (0) } while (0)
#define DBUSERERR(line) do { \
const int e = line; \
if(e != SQLITE_OK && e != SQLITE_ROW && e != SQLITE_DONE) { \
r = sqlite3_errmsg(connection); \
} \
} while(0)
static sqlite3 * connection = NULL; static sqlite3 * connection = NULL;
DECL int DECL int
@ -93,7 +86,7 @@ set_repo(const char * const who, const char * const link)
} }
DECL int DECL int
rtos(void* data, rtos(void * data,
int argc, int argc,
char** argv, char** argv,
char** colname char** colname
@ -128,8 +121,8 @@ DECL char *
raw(const char * const sql) raw(const char * const sql)
{ {
char* errmsg; char* errmsg;
char* r = (char*)calloc(sizeof(char), 10000); // TODO: allow for reallocing in rtos, start with a smaller value char *r = (char*)calloc(sizeof(char), 10000); // TODO: allow for reallocing in rtos, start with a smaller value
DBUSERERR(sqlite3_exec(connection, sql, rtos, &r, &errmsg)); sqlite3_exec(connection, sql, rtos, &r, &errmsg);
if (errmsg){ if (errmsg){
free(r); free(r);
r = errmsg; r = errmsg;