summaryrefslogtreecommitdiffstats
path: root/alsa-binding
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-06-19 15:57:07 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2018-06-26 09:58:01 +0200
commit7799cbdc8f9955e11e5ccf2ffa4beefdaeb6c098 (patch)
tree463e74cba2a2b393d7843dbcde6fe9f877db1532 /alsa-binding
parentf713de4da7b34e030c5f9ac226f3e615c1c77fd3 (diff)
Fixed crash when 'set' request is based on numidsflounder_5.99.1flounder/5.99.15.99.1
When numids are given, the 'tag' field is not initialized to NULL, and leads to a crash on strcasecmp. Change-Id: I23a1552bba565259280140a5e099be10613ab1bc Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'alsa-binding')
-rw-r--r--alsa-binding/Alsa-SetGet.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c
index 9ed316c..a755b02 100644
--- a/alsa-binding/Alsa-SetGet.c
+++ b/alsa-binding/Alsa-SetGet.c
@@ -42,6 +42,7 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl
for (int idx = 0; idx < queryValues->count; idx++) {
json_object *jId, *valuesJ;
ctlRequest[idx].used = 0;
+ ctlRequest[idx].tag = NULL;
ctlRequest[idx].valuesJ = NULL;
// when only one NUMID is provided it might not be encapsulated in a JSON array
@@ -101,7 +102,7 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl
AFB_NOTICE("Invalid Json=%s missing 'val'", json_object_get_string(ctlRequest[idx].jToken));
ctlRequest[idx].used = -1;
} else
- ctlRequest[idx].valuesJ = valuesJ;
+ ctlRequest[idx].valuesJ = valuesJ;
}
}
break;
@@ -720,7 +721,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) {
queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
- // Prase Numids + optional values
+ // Phrase Numids + optional values
done = json_object_object_get_ex(queryJ, "ctl", &numidsJ);
if (!done) queryValues.count = 0;
else {
@@ -769,6 +770,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) {
ctlCount = snd_ctl_elem_list_get_used(ctlList);
if (queryValues.count == 0) {
ctlRequest = alloca(sizeof (ctlRequestT)*(ctlCount));
+ ctlRequest->tag = NULL;
} else {
ctlRequest = alloca(sizeof (ctlRequestT)*(queryValues.count));
NumidsListParse(action, &queryValues, ctlRequest);
@@ -793,9 +795,14 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) {
AFB_NOTICE("snd_ctl_elem_list_get_numid index=%d fail", ctlIndex);
continue;
}
+
// check if current control was requested in query numids list
for (jdx = 0; jdx < queryValues.count; jdx++) {
- if (numid == ctlRequest[jdx].numId || ! strcasecmp(tag, ctlRequest[jdx].tag)) {
+
+ if (numid == ctlRequest[jdx].numId ||
+ (ctlRequest[jdx].tag != NULL &&
+ !strcasecmp(tag, ctlRequest[jdx].tag))
+ ) {
ctlRequest[jdx].numId = numid;
selected = 1;
break;