From 5cdbbe5a5234c1bd26f7fe2a5c59abeb76e6e18c Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Tue, 19 Oct 2010 13:32:54 +0300
Subject: [PATCH] CVE-2010-3389 insecure library loading Bug#598549
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 heartbeat/SAPDatabase |    7 +++++--
 heartbeat/SAPInstance |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/heartbeat/SAPDatabase b/heartbeat/SAPDatabase
index 5e07046..e9574ea 100755
--- a/heartbeat/SAPDatabase
+++ b/heartbeat/SAPDatabase
@@ -966,8 +966,11 @@ else
 fi
 
 # as root user we need the library path to the SAP kernel to be able to call executables
-if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
-  LD_LIBRARY_PATH=$DIR_EXECUTABLE:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
+if [ "$DIR_EXECUTABLE" ]; then
+  if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
+      LD_LIBRARY_PATH="$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+      export LD_LIBRARY_PATH
+  fi
 fi
 sidadm="`echo $SID | tr [:upper:] [:lower:]`adm"
 
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index 08f47f8..d7dea78 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -296,8 +296,11 @@ sapinstance_init() {
   fi
 
   # as root user we need the library path to the SAP kernel to be able to call sapcontrol
-  if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
-    LD_LIBRARY_PATH=$DIR_EXECUTABLE:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
+  if [ "$DIR_EXECUTABLE" ]; then
+    if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
+	LD_LIBRARY_PATH="$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+	export LD_LIBRARY_PATH
+    fi
   fi
 
   sidadm="`echo $SID | tr [:upper:] [:lower:]`adm"
-- 
1.7.1

