blob: 5b84af2c3250798e5317dde695acd3aa04bb15aa [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From f7a4b79b3323534460a63b3e6c58ebaf06adf207 Mon Sep 17 00:00:00 2001
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 14 Jul 2017 13:20:05 -0700
Brad Bishop316dfdd2018-06-25 12:45:53 -04004Subject: [PATCH] v4l2-ctl: Do not use getsubopt
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005
6POSIX says that behavior when subopts list is empty is undefined.
7musl libs will set value to NULL which leads to crash.
8
9Taken from AlpineLinux
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040012
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013---
14 utils/v4l2-ctl/v4l2-ctl-common.cpp | 19 ++++++++++---------
15 1 file changed, 10 insertions(+), 9 deletions(-)
16
17diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
18index 3ea6cd3..291fb3e 100644
19--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
20+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
21@@ -692,16 +692,17 @@ static bool parse_subset(char *optarg)
22
23 static bool parse_next_subopt(char **subs, char **value)
24 {
25- static char *const subopts[] = {
26- NULL
27- };
28- int opt = getsubopt(subs, subopts, value);
29+ char *p = *subs;
30+ *value = *subs;
31
32- if (opt < 0 || *value)
33- return false;
34- fprintf(stderr, "No value given to suboption <%s>\n",
35- subopts[opt]);
36- return true;
37+ while (*p && *p != ',')
38+ p++;
39+
40+ if (*p)
41+ *p++ = '\0';
42+
43+ *subs = p;
44+ return false;
45 }
46
47 void common_cmd(int ch, char *optarg)