diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-03 20:58:09 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-03 20:58:09 +0000 |
commit | 2df1bd44319a60a9beb26511d6e2997a3f4f67ff (patch) | |
tree | abaa97b92ce0717a130b3acb5a60610854c73367 /lib/Driver/OptTable.cpp | |
parent | ddc57332cdc86ed2db28a3b3761b774944937191 (diff) |
Fix invalid reads by memcmp.
Str may be smaller than Start->Name here. Use strncmp to avoid scanning past the
end. Found by valgrind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/OptTable.cpp')
-rw-r--r-- | lib/Driver/OptTable.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp index 680ea9938f..257f3537a1 100644 --- a/lib/Driver/OptTable.cpp +++ b/lib/Driver/OptTable.cpp @@ -162,7 +162,7 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const { 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; |