aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2017-05-31 21:26:00 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2017-05-31 21:28:03 +0200
commitbf732f20e9c9a8dfd0010618908bd458961f3ba4 (patch)
tree7199b6d370c6b2e1c18306ff32c22189c837aded
parent610c7b96b1329b01edcc639534ea5ff25b5f7137 (diff)
downloadaports-bf732f20e9c9a8dfd0010618908bd458961f3ba4.tar.gz
aports-bf732f20e9c9a8dfd0010618908bd458961f3ba4.tar.bz2
aports-bf732f20e9c9a8dfd0010618908bd458961f3ba4.tar.xz
main/v4l-utils: fix segfault due to undefined behavior in getsubopt
ref #7047
-rw-r--r--main/v4l-utils/APKBUILD9
-rw-r--r--main/v4l-utils/getsubopt.patch36
2 files changed, 42 insertions, 3 deletions
diff --git a/main/v4l-utils/APKBUILD b/main/v4l-utils/APKBUILD
index 76a948c5f9..bac61121a6 100644
--- a/main/v4l-utils/APKBUILD
+++ b/main/v4l-utils/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=v4l-utils
pkgver=1.12.5
-pkgrel=0
+pkgrel=1
pkgdesc="Userspace tools and conversion library for Video 4 Linux"
url="http://freshmeat.net/projects/libv4l"
arch="all"
@@ -12,7 +12,9 @@ subpackages="$pkgname-dev $pkgname-doc qv4l2 $pkgname-dvbv5 $pkgname-libs ir_key
source="http://linuxtv.org/downloads/v4l-utils/$pkgname-$pkgver.tar.bz2
qv4l2.svg
qv4l2.desktop
- 0001-ir-ctl-fixes-for-musl-compile.patch"
+ 0001-ir-ctl-fixes-for-musl-compile.patch
+ getsubopt.patch
+ "
builddir="$srcdir"/$pkgname-$pkgver
check() {
@@ -89,4 +91,5 @@ ir_keytable() {
sha512sums="ed2e7545a728360b9684db68330885b498a3a5611f49b80e54da72109d9ba2aa75e85f89f085ff0a6f077b17c880101fa5b78c9dff8a0df2eac1866bd80a04ea v4l-utils-1.12.5.tar.bz2
bc18280046c15b19984103f7c2bb44a0aea79715803c64f0c64bc932499c09022c956914c3b15ae59499adc09f6fbff5378be45707fe851250f495a26b63d682 qv4l2.svg
6f74aa524b3de420eeb8de788ff3f717020732a3f1f6530caee50e63aae7eddbe5f551ffc50065c9f5d6078c13bace089948ecdcacf01f8b82c1a44960e06315 qv4l2.desktop
-f93d18b282d52c6cccbedc489e201a19b59f44b5e0aeb74b96537c3f5797c0b3c3f1499cd6ae822715c712e92b5ec5749749394f004ae1887a8bae3bac117c5b 0001-ir-ctl-fixes-for-musl-compile.patch"
+f93d18b282d52c6cccbedc489e201a19b59f44b5e0aeb74b96537c3f5797c0b3c3f1499cd6ae822715c712e92b5ec5749749394f004ae1887a8bae3bac117c5b 0001-ir-ctl-fixes-for-musl-compile.patch
+9a4f6d0a44d30bb7afe4db8b40074d362f240cae1f1b13feb0eb2b1b666479fc6f73ef27542f6f80fb1b922c9540feadc9ff8563890ff3041d3f7fc62e504e29 getsubopt.patch"
diff --git a/main/v4l-utils/getsubopt.patch b/main/v4l-utils/getsubopt.patch
new file mode 100644
index 0000000000..c476e5ed7e
--- /dev/null
+++ b/main/v4l-utils/getsubopt.patch
@@ -0,0 +1,36 @@
+POSIX says that behavior when subopts list is empty is undefined.
+musl libs will set value to NULL which leads to crash.
+
+Simply avoid getsubopt, since we cannot rely on it.
+
+diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
+index 3ea6cd3..291fb3e 100644
+--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
++++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
+@@ -692,16 +692,17 @@ static bool parse_subset(char *optarg)
+
+ static bool parse_next_subopt(char **subs, char **value)
+ {
+- static char *const subopts[] = {
+- NULL
+- };
+- int opt = getsubopt(subs, subopts, value);
++ char *p = *subs;
++ *value = *subs;
+
+- if (opt < 0 || *value)
+- return false;
+- fprintf(stderr, "No value given to suboption <%s>\n",
+- subopts[opt]);
+- return true;
++ while (*p && *p != ',')
++ p++;
++
++ if (*p)
++ *p++ = '\0';
++
++ *subs = p;
++ return false;
+ }
+
+ void common_cmd(int ch, char *optarg)