From 770e115d39595b717e01daf3e0ea6c80bc8390c4 Mon Sep 17 00:00:00 2001 From: maxice8 Date: Sun, 20 Jan 2019 12:25:54 -0200 Subject: [PATCH] xinit: fix buffer overflow when too many arguments are given See: https://lists.x.org/archives/xorg-devel/2019-January/057886.html --- .../xinit/patches/fix-buffer-overflow.patch | 39 +++++++++++++++++++ srcpkgs/xinit/template | 17 ++++---- 2 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 srcpkgs/xinit/patches/fix-buffer-overflow.patch diff --git a/srcpkgs/xinit/patches/fix-buffer-overflow.patch b/srcpkgs/xinit/patches/fix-buffer-overflow.patch new file mode 100644 index 00000000000..4c41e30610b --- /dev/null +++ b/srcpkgs/xinit/patches/fix-buffer-overflow.patch @@ -0,0 +1,39 @@ +Signed-off-by: Tobias Stoeckmann +--- + xinit.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/xinit.c b/xinit.c +index f826b7a..8efd0be 100644 +--- xinit.c ++++ xinit.c +@@ -151,7 +151,6 @@ main(int argc, char *argv[]) + register char **ptr; + pid_t pid; + int client_given = 0, server_given = 0; +- int client_args_given = 0, server_args_given = 0; + int start_of_client_args, start_of_server_args; + struct sigaction sa, si; + #ifdef __APPLE__ +@@ -174,7 +173,8 @@ main(int argc, char *argv[]) + } + start_of_client_args = (cptr - client); + while (argc && strcmp(*argv, "--")) { +- client_args_given++; ++ if (cptr > clientargv + 98) ++ Fatalx("too many client arguments"); + *cptr++ = *argv++; + argc--; + } +@@ -202,7 +202,8 @@ main(int argc, char *argv[]) + + start_of_server_args = (sptr - server); + while (--argc >= 0) { +- server_args_given++; ++ if (sptr > serverargv + 98) ++ Fatalx("too many server arguments"); + *sptr++ = *argv++; + } + *sptr = NULL; +-- +2.20.1 diff --git a/srcpkgs/xinit/template b/srcpkgs/xinit/template index cd78be3610d..96aa9621149 100644 --- a/srcpkgs/xinit/template +++ b/srcpkgs/xinit/template @@ -1,22 +1,23 @@ -# Template build file for 'xinit'. +# Template file for 'xinit' pkgname=xinit version=1.4.0 -revision=3 +revision=4 build_style=gnu-configure configure_args="--with-xinitdir=/etc/X11/xinit" hostmakedepends="pkg-config" makedepends="libX11-devel" +short_desc="X init program" +maintainer="Juan RP " +license="MIT" +homepage="http://xorg.freedesktop.org/" +distfiles="${XORG_SITE}/app/${pkgname}-${version}.tar.bz2" +checksum=230835eef2f5978a1e1344928168119373f6df1d0a32c09515e545721ee582ef + conf_files=" /etc/X11/xinit/xinitrc /etc/X11/xinit/xserverrc /etc/skel/.xinitrc /etc/skel/.xsession" -short_desc="X init program" -maintainer="Juan RP " -homepage="http://xorg.freedesktop.org/" -license="MIT" -distfiles="${XORG_SITE}/app/$pkgname-$version.tar.bz2" -checksum=230835eef2f5978a1e1344928168119373f6df1d0a32c09515e545721ee582ef post_install() { vinstall ${FILESDIR}/xinitrc 644 etc/skel .xinitrc