blob: d8d1b8d18465b4297088a42a286953a060ebcb89 [file] [log] [blame]
Andrew Geissler9aee5002022-03-30 16:27:02 +00001From e4582c11f76b9390a3e172dcf0741dca90a9dc8d Mon Sep 17 00:00:00 2001
Brad Bishope42b3e32020-01-15 22:08:42 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 30 Nov 2019 18:50:34 -0800
4Subject: [PATCH] Do not use getsubopt
5
6POSIX says that behavior when subopts list is empty is undefined.
7musl libs will set value to NULL which leads to crash.
8
9Simply avoid getsubopt, since we cannot rely on it.
10
11Imported from Alpine Linux
12
13Upstream-Status: Pending
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
Andrew Geissler9aee5002022-03-30 16:27:02 +000015
Brad Bishope42b3e32020-01-15 22:08:42 -050016---
17 utils/v4l2-ctl/v4l2-ctl-common.cpp | 18 ++++++++++--------
18 1 file changed, 10 insertions(+), 8 deletions(-)
19
20diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
Andrew Geissler9aee5002022-03-30 16:27:02 +000021index c940171..49c0f39 100644
Brad Bishope42b3e32020-01-15 22:08:42 -050022--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
23+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
Andrew Geissler9aee5002022-03-30 16:27:02 +000024@@ -956,15 +956,17 @@ static bool parse_subset(char *optarg)
Brad Bishope42b3e32020-01-15 22:08:42 -050025
26 static bool parse_next_subopt(char **subs, char **value)
27 {
28- static char *const subopts[] = {
Andrew Geissler9aee5002022-03-30 16:27:02 +000029- nullptr
Brad Bishope42b3e32020-01-15 22:08:42 -050030- };
31- int opt = getsubopt(subs, subopts, value);
32+ char *p = *subs;
33+ *value = *subs;
34
35- if (opt < 0 || *value)
36- return false;
37- fprintf(stderr, "Missing suboption value\n");
38- return true;
39+ while (*p && *p != ',')
40+ p++;
41+
42+ if (*p)
43+ *p++ = '\0';
44+
45+ *subs = p;
46+ return false;
47 }
48
49 void common_cmd(const std::string &media_bus_info, int ch, char *optarg)