c476e5ed7e7ac40f58aa566a6c31255fe58e29cf
[feed/packages.git] / libs / libv4l / patches / 030-getsubopt.patch
1 POSIX says that behavior when subopts list is empty is undefined.
2 musl libs will set value to NULL which leads to crash.
3
4 Simply avoid getsubopt, since we cannot rely on it.
5
6 diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
7 index 3ea6cd3..291fb3e 100644
8 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
9 +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
10 @@ -692,16 +692,17 @@ static bool parse_subset(char *optarg)
11
12 static bool parse_next_subopt(char **subs, char **value)
13 {
14 - static char *const subopts[] = {
15 - NULL
16 - };
17 - int opt = getsubopt(subs, subopts, value);
18 + char *p = *subs;
19 + *value = *subs;
20
21 - if (opt < 0 || *value)
22 - return false;
23 - fprintf(stderr, "No value given to suboption <%s>\n",
24 - subopts[opt]);
25 - return true;
26 + while (*p && *p != ',')
27 + p++;
28 +
29 + if (*p)
30 + *p++ = '\0';
31 +
32 + *subs = p;
33 + return false;
34 }
35
36 void common_cmd(int ch, char *optarg)