[Lldb-commits] [lldb] r226544 - Fix creation of StringRef in FileSpec::ResolveUsername()

Zachary Turner zturner at google.com
Mon Jan 19 20:27:19 PST 2015


While it's true that SmallString, and hence SmallVector support non
null-terminated strings, it worries me if we have a non null-terminated
string somewhere in LLDB.

On Mon Jan 19 2015 at 8:25:17 PM Jason Molenda <jmolenda at apple.com> wrote:

> Author: jmolenda
> Date: Mon Jan 19 22:20:42 2015
> New Revision: 226544
>
> URL: http://llvm.org/viewvc/llvm-project?rev=226544&view=rev
> Log:
> Fix creation of StringRef in FileSpec::ResolveUsername()
> so it doesn't assume that the SmallVector<char> will have
> nul terminator.  It did not in at least one case.
> Caught by ASAN instrumentation.
>
> Modified:
>     lldb/trunk/source/Host/common/FileSpec.cpp
>
> Modified: lldb/trunk/source/Host/common/FileSpec.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/
> Host/common/FileSpec.cpp?rev=226544&r1=226543&r2=226544&view=diff
> ============================================================
> ==================
> --- lldb/trunk/source/Host/common/FileSpec.cpp (original)
> +++ lldb/trunk/source/Host/common/FileSpec.cpp Mon Jan 19 22:20:42 2015
> @@ -65,7 +65,7 @@ FileSpec::ResolveUsername (llvm::SmallVe
>      if (path.empty() || path[0] != '~')
>          return;
>
> -    llvm::StringRef path_str(path.data());
> +    llvm::StringRef path_str(path.data(), path.size());
>      size_t slash_pos = path_str.find_first_of("/", 1);
>      if (slash_pos == 1 || path.size() == 1)
>      {
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150120/e239d509/attachment.html>


More information about the lldb-commits mailing list