summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolVendor
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-02-27 19:43:08 +0000
committerIlia K <ki.stfu@gmail.com>2015-02-27 19:43:08 +0000
commit54a3368f7acbd827bb5752fc1f1a586f92e9c42a (patch)
tree37275316c8ad7af610b8a381182751708298a466 /lldb/source/Plugins/SymbolVendor
parenteb3fe143076a0b9941ea7d786f775ccc108b9b3e (diff)
Fix FileSpec::GetPath to return null-terminated strings
Summary: Before this fix the FileSpec::GetPath() returned string which might be without '\0' at the end. It could have happened if the size of buffer for path was less than actual path. Test case: ``` FileSpec test("/path/to/file", false); char buf[]="!!!!!!"; test.GetPath(buf, 3); ``` Before fix: ``` 233 FileSpec test("/path/to/file", false); 234 char buf[]="!!!!!!"; 235 test.GetPath(buf, 3); 236 -> 237 if (core_file) 238 { 239 if (!core_file.Exists()) 240 { (lldb) print buf (char [7]) $0 = "/pa!!!" ``` After fix: ``` 233 FileSpec test("/path/to/file", false); 234 char buf[]="!!!!!!"; 235 test.GetPath(buf, 3); 236 -> 237 if (core_file) 238 { 239 if (!core_file.Exists()) 240 { (lldb) print buf (char [7]) $0 = "/p" ``` Reviewers: zturner, abidh, clayborg Reviewed By: abidh, clayborg Subscribers: tberghammer, vharron, lldb-commits, clayborg, zturner, abidh Differential Revision: http://reviews.llvm.org/D7553
Diffstat (limited to 'lldb/source/Plugins/SymbolVendor')
-rw-r--r--lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index a70c5d57114..f647ac43465 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -231,7 +231,7 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp, lldb_privat
const char *node_content = (const char *)::xmlNodeGetContent(value_node);
if (node_content)
{
- strncpy(DBGBuildSourcePath, node_content, sizeof(DBGBuildSourcePath));
+ ::snprintf(DBGBuildSourcePath, sizeof(DBGBuildSourcePath), "%s", node_content);
xmlFree((void *) node_content);
}
}