From c52af696ca187fa592ae5bf90f5b336d6322eb2a Mon Sep 17 00:00:00 2001 From: Kazimierz Krosman Date: Fri, 26 Aug 2016 15:39:47 +0200 Subject: [PATCH] Fix: wrong data preparation for policy requests Additional Fix: wrong assertion (name validation) Change-Id: I79fa2bc27f8a8406f067bc7e4299bdc422c79b37 --- src/internal/internal.cpp | 4 ++-- src/internal/policy.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/internal/internal.cpp b/src/internal/internal.cpp index ff19d1b..2849ea0 100644 --- a/src/internal/internal.cpp +++ b/src/internal/internal.cpp @@ -97,8 +97,8 @@ int __internal_can_send_multi_dest(bool bus_type, int i = 0; ldp_xml_parser::MatchItemSR matcher(interface, member, path, static_cast(type), ldp_xml_parser::MessageDirection::SEND); if (destination) - while (destination[i++]) { - matcher.addName(destination[i]); + while (destination[i]) { + matcher.addName(destination[i++]); } return static_cast(policy_checker.check(bus_type, user, group, label, matcher, ldp_xml_parser::ItemType::SEND)); } diff --git a/src/internal/policy.cpp b/src/internal/policy.cpp index 9bcdb63..96ddde1 100644 --- a/src/internal/policy.cpp +++ b/src/internal/policy.cpp @@ -1,5 +1,6 @@ #include "policy.hpp" #include "naive_policy_db.hpp" +#include "tslog.hpp" #include #include #include @@ -268,11 +269,13 @@ bool MatchItemSR::addNames(const char* name) { int j = 0; if (name) { - assert((name[i] > 'a'&& name[i] < 'z') || (name[i] > 'A'&& name[i] < 'Z') || (name[i] > '0'&& name[i] < '9')); while (name[i] && names_num < KDBUS_CONN_MAX_NAMES + 1) { char c; int len; j = i; + if (tslog::verbose() && !(name[i] >= 'a'&& name[i] <= 'z') || (name[i] >= 'A'&& name[i] <= 'Z') || (name[i] >= '0'&& name[i] <= '9') || name[i] == ' ') { + std::cout<<"Wrong name("<