[Lldb-commits] [lldb] r316740 - Fix a use-after-free in lldb-server
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 31 08:12:54 PDT 2017
The takeaway from this example is nothing we don't already know. We need
better test coverage.
On Tue, Oct 31, 2017 at 8:08 AM Greg Clayton via lldb-commits <
lldb-commits at lists.llvm.org> wrote:
> This is one example of how StringRef causes issues because it was adopted
> everywhere. Is there any way we can change our functions so we can't run
> into this issue? Anything we can learn from this example?
>
>
>
> > On Oct 26, 2017, at 9:53 PM, Pavel Labath via lldb-commits <
> lldb-commits at lists.llvm.org> wrote:
> >
> > Author: labath
> > Date: Thu Oct 26 21:53:24 2017
> > New Revision: 316740
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=316740&view=rev
> > Log:
> > Fix a use-after-free in lldb-server
> >
> > UriParser::Parse is returning a StringRef pointing the the parsed
> > string, but we were calling it with a temporary string. Change this to a
> > local variable to make sure the string persists as long as we need it.
> >
> > Modified:
> >
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=316740&r1=316739&r2=316740&view=diff
> >
> ==============================================================================
> > ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
> Thu Oct 26 21:53:24 2017
> > @@ -128,8 +128,9 @@ Status GDBRemoteCommunicationServerPlatf
> > llvm::StringRef platform_ip;
> > int platform_port;
> > llvm::StringRef platform_path;
> > - bool ok = UriParser::Parse(GetConnection()->GetURI(), platform_scheme,
> > - platform_ip, platform_port, platform_path);
> > + std::string platform_uri = GetConnection()->GetURI();
> > + bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip,
> > + platform_port, platform_path);
> > UNUSED_IF_ASSERT_DISABLED(ok);
> > assert(ok);
> >
> >
> >
> > _______________________________________________
> > lldb-commits mailing list
> > lldb-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171031/85514768/attachment.html>
More information about the lldb-commits
mailing list