From 25fd85f513ea32054cf3bba5bf7f47d059a45e6b Mon Sep 17 00:00:00 2001 From: Djalal Harouni Date: Fri, 24 Oct 2014 23:11:49 +0100 Subject: [PATCH] names: check if name is valid for CMD_NAME_ACQUIRE and CMD_NAME_RELEASE Signed-off-by: Djalal Harouni --- kdbus.txt | 2 +- names.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kdbus.txt b/kdbus.txt index d5079aa..846d195 100644 --- a/kdbus.txt +++ b/kdbus.txt @@ -1771,7 +1771,7 @@ For KDBUS_CMD_NAME_ACQUIRE: For KDBUS_CMD_NAME_RELEASE: - -EINVAL Invalid command flags provided + -EINVAL Invalid command flags, or invalid name provided -ESRCH Name is not found found in the registry -EADDRINUSE Name is owned by a different connection and can't be released diff --git a/names.c b/names.c index 02efef3..5f8853c 100644 --- a/names.c +++ b/names.c @@ -4,6 +4,7 @@ * Copyright (C) 2013-2014 Daniel Mack * Copyright (C) 2013-2014 David Herrmann * Copyright (C) 2013-2014 Linux Foundation + * Copyright (C) 2014 Djalal Harouni * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the @@ -647,6 +648,9 @@ int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg, if (ret < 0) return -EINVAL; + if (!kdbus_name_is_valid(name, false)) + return -EINVAL; + /* * Do atomic_inc_return here to reserve our slot, then decrement * it before returning. @@ -688,6 +692,9 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg, if (ret < 0) return -EINVAL; + if (!kdbus_name_is_valid(name, false)) + return -EINVAL; + ret = kdbus_ep_policy_check_see_access(conn->ep, conn, name); if (ret < 0) return ret; -- 2.34.1