[cfe-commits] r165157 - /cfe/trunk/lib/Driver/OptTable.cpp
Benjamin Kramer
benny.kra at googlemail.com
Wed Oct 3 13:58:10 PDT 2012
Author: d0k
Date: Wed Oct 3 15:58:09 2012
New Revision: 165157
URL: http://llvm.org/viewvc/llvm-project?rev=165157&view=rev
Log:
Fix invalid reads by memcmp.
Str may be smaller than Start->Name here. Use strncmp to avoid scanning past the
end. Found by valgrind.
Modified:
cfe/trunk/lib/Driver/OptTable.cpp
Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=165157&r1=165156&r2=165157&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Wed Oct 3 15:58:09 2012
@@ -162,7 +162,7 @@
for (; Start != End; ++Start) {
// Scan for first option which is a proper prefix.
for (; Start != End; ++Start)
- if (memcmp(Str, Start->Name, strlen(Start->Name)) == 0)
+ if (strncmp(Str, Start->Name, strlen(Start->Name)) == 0)
break;
if (Start == End)
break;
More information about the cfe-commits
mailing list