summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-04-30 08:45:37 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-04-30 08:49:05 -0700
commit6980e5c3b7151745c5303253702293d4edb8e852 (patch)
tree38bb1da8b0d375f363d3730ccad72ff920b4d01f
parentc723097e1238780420814a184349a9ca950e2557 (diff)
binding: mediaplayer: fix segfault in volume commandguppy_7.0.2guppy/7.0.27.0.2
When no volume field is passed it caused a null pointer dereference Bug-AGL: SPEC-2368 Change-Id: Ia11ae28b38455a597d1b31a044a711e21928b0cc Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-mediaplayer-binding.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 9eea30e..4720b63 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -507,7 +507,15 @@ static void gstreamer_controls(afb_req_t request)
}
case VOLUME_CMD: {
const char *parameter = afb_req_value(request, "volume");
- long int volume = strtol(parameter, NULL, 10);
+ long int volume;
+
+ if (!parameter) {
+ afb_req_fail(request, "failed", "invalid volume");
+ return;
+ }
+
+ volume = strtol(parameter, NULL, 10);
+ errno = 0;
if (volume == 0 && errno) {
afb_req_fail(request, "failed", "invalid volume");