]> granicus.if.org Git - icinga2/commitdiff
Fix invalid notification_id in DB IDO query
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 15 Dec 2015 10:55:21 +0000 (11:55 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 15 Dec 2015 10:59:06 +0000 (11:59 +0100)
fixes #8976

lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp

index dbaf2edb69668e24a936e3feb31ef3be3bb718f3..b1e1fc196d8faafea83f54c6ab24c463a364334e 100644 (file)
@@ -682,13 +682,16 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
        if (key == "instance_id") {
                *result = static_cast<long>(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<long>(GetNotificationInsertID(value));
+       } else if (key == "notification_id") {
+               DbReference ref = GetNotificationInsertID(value);
+
+               if (!ref.IsValid())
+                       return false;
+
+               *result = static_cast<long>(ref);
                return true;
        }
 
index 46a94c0639e99f02bb9780a770808e49ab63414e..29a0588481c4cbd31e007d9728d6c11200f93b4f 100644 (file)
@@ -565,13 +565,16 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
        if (key == "instance_id") {
                *result = static_cast<long>(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<long>(GetNotificationInsertID(value));
+       } else if (key == "notification_id") {
+               DbReference ref = GetNotificationInsertID(value);
+
+               if (!ref.IsValid())
+                       return false;
+
+               *result = static_cast<long>(ref);
                return true;
        }