Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201557

[PATCH 9/9] kdbus/tests: properly parse KDBUS_CMD_LIST objects

From David Herrmann <dh.herrmann@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 9/9] kdbus/tests: properly parse KDBUS_CMD_LIST objects
Date 2015-08-06 10:30 +0200
Message-ID <pUoIO-3l2-13@gated-at.bofh.it> (permalink)
References <pUoIN-3l2-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


There is no reason to assume the information returned by KDBUS_CMD_LIST
contains only a single KDBUS_ITEM_OWNED_NAME. Parse each of them properly
and don't bail out early.

Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 tools/testing/selftests/kdbus/kdbus-util.c |  9 +++++----
 tools/testing/selftests/kdbus/test-names.c | 17 +++++++++++------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/kdbus/kdbus-util.c b/tools/testing/selftests/kdbus/kdbus-util.c
index a5e54ca..82fa89b 100644
--- a/tools/testing/selftests/kdbus/kdbus-util.c
+++ b/tools/testing/selftests/kdbus/kdbus-util.c
@@ -1155,11 +1155,12 @@ int kdbus_list(struct kdbus_conn *conn, uint64_t flags)
 			if (item->type == KDBUS_ITEM_OWNED_NAME) {
 				n = item->name.name;
 				flags = item->name.flags;
-			}
 
-		kdbus_printf("%8llu flags=0x%08llx conn=0x%08llx '%s'\n",
-			     name->id, (unsigned long long) flags,
-			     name->flags, n);
+				kdbus_printf("%8llu flags=0x%08llx conn=0x%08llx '%s'\n",
+					     name->id,
+					     (unsigned long long) flags,
+					     name->flags, n);
+			}
 	}
 	kdbus_printf("\n");
 
diff --git a/tools/testing/selftests/kdbus/test-names.c b/tools/testing/selftests/kdbus/test-names.c
index 66ebb47..fd4ac5a 100644
--- a/tools/testing/selftests/kdbus/test-names.c
+++ b/tools/testing/selftests/kdbus/test-names.c
@@ -35,15 +35,20 @@ static int conn_is_name_owner(const struct kdbus_conn *conn,
 		struct kdbus_item *item;
 		const char *n = NULL;
 
-		KDBUS_ITEM_FOREACH(item, name, items)
-			if (item->type == KDBUS_ITEM_OWNED_NAME)
+		KDBUS_ITEM_FOREACH(item, name, items) {
+			if (item->type == KDBUS_ITEM_OWNED_NAME) {
 				n = item->name.name;
 
-		if (name->id == conn->id &&
-		    n && strcmp(needle, n) == 0) {
-			found = true;
-			break;
+				if (name->id == conn->id &&
+				    n && strcmp(needle, n) == 0) {
+					found = true;
+					break;
+				}
+			}
 		}
+
+		if (found)
+			break;
 	}
 
 	ret = kdbus_free(conn, cmd_list.offset);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] kdbus: set of random fixes David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 7/9] kdbus: consolidate common code David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 4/9] kdbus: move privilege checking in kdbus_conn_new() David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 9/9] kdbus/tests: properly parse KDBUS_CMD_LIST objects David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 1/9] kdbus: return EBADSLT on replies without slot David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 2/9] kdbus: reduce stack buffer to 256 bytes David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 3/9] kdbus: use separate counter for message IDs David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 5/9] kdbus: perform accounting on proxied uids David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 6/9] kdbus: inline privilege checks David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200

csiph-web