403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/devel/google-perftools/files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/devel/google-perftools/files/patch-src_base_dynamic__annotations.c
- add another way to determine if the process is run under valgrind - based on LD_PRELOAD patterns presence
- Submitted: https://github.com/gperftools/gperftools/pull/1316

--- src/base/dynamic_annotations.c.orig	2021-02-15 06:44:21 UTC
+++ src/base/dynamic_annotations.c
@@ -43,6 +43,21 @@
 #include "base/dynamic_annotations.h"
 #include "getenv_safe.h" // for TCMallocGetenvSafe
 
+static int running_on_valgrind_preload = -1;
+void __attribute__ ((constructor)) premain() {
+  char *LD_PRELOAD = getenv("LD_PRELOAD");
+  if (LD_PRELOAD == NULL)
+    LD_PRELOAD = getenv("LD_32_PRELOAD");
+  running_on_valgrind_preload = LD_PRELOAD != NULL &&
+    (
+      strstr(LD_PRELOAD, "/valgrind/") != NULL
+      ||
+      strstr(LD_PRELOAD, "/vgpreload") != NULL
+    )
+    ?
+    1 : 0;
+}
+
 static int GetRunningOnValgrind(void) {
 #ifdef RUNNING_ON_VALGRIND
   if (RUNNING_ON_VALGRIND) return 1;
@@ -51,6 +66,11 @@ static int GetRunningOnValgrind(void) {
   if (running_on_valgrind_str) {
     return strcmp(running_on_valgrind_str, "0") != 0;
   }
+
+  // use the LD_PRELOAD trick from https://stackoverflow.com/questions/365458/how-can-i-detect-if-a-program-is-running-from-within-valgrind
+  if (running_on_valgrind_preload == 1)
+    return 1;
+
   return 0;
 }
 

Youez - 2016 - github.com/yon3zu
LinuXploit