mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 18:56:21 +00:00
database: make log_database_get_previous_chat safer
This commit is contained in:
@@ -214,6 +214,8 @@ log_database_get_previous_chat(const gchar* const contact_barejid)
|
||||
char* query;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
if (!myjid)
|
||||
return NULL;
|
||||
|
||||
if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE (`from_jid` = '%s' AND `to_jid` = '%s') OR (`from_jid` = '%s' AND `to_jid` = '%s') ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid) == -1) {
|
||||
log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
|
||||
|
||||
Reference in New Issue
Block a user