summaryrefslogtreecommitdiffstats
path: root/binding/afm-nfc-binding.c
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2018-12-03 20:39:22 +0200
committerRaquel Medina <raquel.medina@konsulko.com>2018-12-04 00:27:45 +0200
commitaab5e5d8ff58b2ec6503615efb9ea35e9f0d93f2 (patch)
treec1e0ef281cdcebd33648d3ba2242dece1be40062 /binding/afm-nfc-binding.c
parent807f399fb2923fbbdf516628a28215ddcdb9185e (diff)
binding: nfc: check request value field on subscribe & unsubscribeguppy_6.99.3guppy/6.99.36.99.3
Bug-AGL: SPEC-1994 - check subscribe/unsubscribe requests from client are for a valid event. Change-Id: Icb020e35f2c70a83b1a043a03827d25ed2e94d17 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com>
Diffstat (limited to 'binding/afm-nfc-binding.c')
-rw-r--r--binding/afm-nfc-binding.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/binding/afm-nfc-binding.c b/binding/afm-nfc-binding.c
index eb667de..5331d6c 100644
--- a/binding/afm-nfc-binding.c
+++ b/binding/afm-nfc-binding.c
@@ -281,10 +281,18 @@ static int init(afb_api_t api)
static void subscribe(afb_req_t request)
{
+ const char *value = afb_req_value(request, "value");
+ const char *ename = afb_event_name(presence_event);
+
+ if (!value || !ename)
+ return;
+
+ if (strcasecmp(value, ename))
+ return;
+
if (afb_req_subscribe(request, presence_event) < 0) {
AFB_REQ_ERROR(request, "subscribe to presence_event failed");
afb_req_reply(request, NULL, "failed", "Invalid event");
-
return;
}
@@ -293,10 +301,18 @@ static void subscribe(afb_req_t request)
static void unsubscribe(afb_req_t request)
{
+ const char *value = afb_req_value(request, "value");
+ const char *ename = afb_event_name(presence_event);
+
+ if (!value || !ename)
+ return;
+
+ if (strcasecmp(value, ename))
+ return;
+
if (afb_req_unsubscribe(request, presence_event) < 0) {
AFB_REQ_ERROR(request, "unsubscribe to presence_event failed");
afb_req_reply(request, NULL, "failed", "Invalid event");
-
return;
}