[Lldb-commits] [lldb] r123307 - /lldb/trunk/source/Host/common/Host.cpp

Stephen Wilson wilsons at start.ca
Tue Jan 11 20:21:22 PST 2011


Author: wilsons
Date: Tue Jan 11 22:21:21 2011
New Revision: 123307

URL: http://llvm.org/viewvc/llvm-project?rev=123307&view=rev
Log:
Null terminate path returned by readlink().


Modified:
    lldb/trunk/source/Host/common/Host.cpp

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=123307&r1=123306&r2=123307&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Jan 11 22:21:21 2011
@@ -620,9 +620,11 @@
         }
 #elif defined (__linux__)
         char exe_path[PATH_MAX];
-        ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
-        if (len >= 0)
+        ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
+        if (len > 0) {
+            exe_path[len] = 0;
             g_program_filespec = FileSpec(exe_path, true);
+        }
 #elif defined (__FreeBSD__)
         int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() };
         size_t exe_path_size;





More information about the lldb-commits mailing list