Hi,

This patch fixes an array-out-of-bounds memory access issue.

I stumbled upon this bug by pure chance after constantly getting signal 11s
from a WindowMaker built with gcc 4.7 (I used 4.4 until now).
gcc 4.4 and previous versions didn't show any obvious issue even though
some memory has always been overwritten.

-- 
Francois Tigeot
>From b285faaadf2499e43585eff178f429a76d779d95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Tigeot?= <[email protected]>
Date: Sat, 21 Sep 2013 12:34:51 +0200
Subject: [PATCH] osdep_bsd.c: Fix a typo causing memory to be overwritten

* When compiled on DragonFly+gcc 4.7.3, this out of bounds array element
  initialization causes an important variable to be overwritten and a
  subsequent WindowMaker crash

* It was sheer luck other compilers/environments didn't exhibit any obvious
  issue so far
---
 src/osdep_bsd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/osdep_bsd.c b/src/osdep_bsd.c
index 3393240..ad504ad 100644
--- a/src/osdep_bsd.c
+++ b/src/osdep_bsd.c
@@ -86,7 +86,7 @@ Bool GetCommandForPid(int pid, char ***argv, int *argc)
 		mib[0] = CTL_KERN;
 		mib[1] = KERN_ARGMAX;
 		mib[2] = 0;
-		mib[4] = 0;
+		mib[3] = 0;
 
 		count = sizeof(argmax);
 		if (sysctl(mib, 2, &argmax, &count, NULL, 0) == -1)
-- 
1.8.4

Reply via email to