1
From bd20bb02e75e2c0483832b52f2577253febfb690 Mon Sep 17 00:00:00 2001
2
From: Kjetil Matheussen <k.s.matheussen@usit.uio.no>
3
Date: Wed, 1 Apr 2015 16:06:48 +0200
4
Subject: [PATCH] Fix memory overflow if the name of an environment is larger
5
than 500 characters. Bug found by Adam Sampson.
8
das_watchdog.c | 10 +++++++++-
9
1 file changed, 9 insertions(+), 1 deletion(-)
11
diff --git a/das_watchdog.c b/das_watchdog.c
12
index c98bbea..8473fe8 100644
15
@@ -306,7 +306,9 @@ static int checksoftirq(int force){
18
static char *get_pid_environ_val(pid_t pid,char *val){
20
+ int temp_size = 500;
21
+ char *temp = malloc(temp_size);
26
@@ -319,6 +321,12 @@ static char *get_pid_environ_val(pid_t pid,char *val){
31
+ if (i >= temp_size) {
33
+ temp = realloc(temp, temp_size);
38
if(foundit==1 && (temp[i]==0 || temp[i]=='\0' || temp[i]==EOF)){