From 36c170d5dc5da055735c76edad44e798583f78bb Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 15 Dec 2015 11:55:21 +0100 Subject: [PATCH] Fix invalid notification_id in DB IDO query fixes #8976 --- lib/db_ido_mysql/idomysqlconnection.cpp | 13 ++++++++----- lib/db_ido_pgsql/idopgsqlconnection.cpp | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 697b7395e..719770837 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -682,13 +682,16 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va if (key == "instance_id") { *result = static_cast(m_InstanceID); return true; - } - if (key == "session_token") { + } else if (key == "session_token") { *result = m_SessionToken; return true; - } - if (key == "notification_id") { - *result = static_cast(GetNotificationInsertID(value)); + } else if (key == "notification_id") { + DbReference ref = GetNotificationInsertID(value); + + if (!ref.IsValid()) + return false; + + *result = static_cast(ref); return true; } diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index a0a63007d..977e8babb 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -565,13 +565,16 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va if (key == "instance_id") { *result = static_cast(m_InstanceID); return true; - } - if (key == "session_token") { + } else if (key == "session_token") { *result = m_SessionToken; return true; - } - if (key == "notification_id") { - *result = static_cast(GetNotificationInsertID(value)); + } else if (key == "notification_id") { + DbReference ref = GetNotificationInsertID(value); + + if (!ref.IsValid()) + return false; + + *result = static_cast(ref); return true; }