[Lldb-commits] [PATCH] D36620: Fix crash on parsing gdb remote packets

Christopher Book via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 11 09:42:34 PDT 2017


cbook created this revision.

Prevent negative chars from being sign-extended into isprint and isspace which take and int and crash if the int is negative.


https://reviews.llvm.org/D36620

Files:
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp


Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -815,7 +815,8 @@
         // checksum
         if (m_bytes[0] == '$' && total_length > 4) {
           for (size_t i = 0; !binary && i < total_length; ++i) {
-            if (isprint(m_bytes[i]) == 0 && isspace(m_bytes[i]) == 0) {
+            unsigned char c = m_bytes[i];
+            if (isprint(c) == 0 && isspace(c) == 0) {
               binary = true;
             }
           }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36620.110747.patch
Type: text/x-patch
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170811/70e9853d/attachment-0001.bin>


More information about the lldb-commits mailing list