mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
win getopt: memcmp() -> strncmp() for ASan
R=mark@chromium.org BUG=chromium:635990 Change-Id: I69f0e1f0f48c6d0d2ac26eb395df7add2907d02b Reviewed-on: https://chromium-review.googlesource.com/367350 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
18a839c810
commit
56b14bceef
2
third_party/getopt/README.crashpad
vendored
2
third_party/getopt/README.crashpad
vendored
@ -13,3 +13,5 @@ Local Modifications:
|
|||||||
- Add copy of copyright (Public domain) to the top of both files for Chromium's
|
- Add copy of copyright (Public domain) to the top of both files for Chromium's
|
||||||
checklicenses step.
|
checklicenses step.
|
||||||
- Compiled as .cc, and wrapped in namespace crashpad.
|
- Compiled as .cc, and wrapped in namespace crashpad.
|
||||||
|
- memcmp() -> strncmp() in getopt.cc to make ASan happier about some string
|
||||||
|
manipulation.
|
||||||
|
8
third_party/getopt/getopt.cc
vendored
8
third_party/getopt/getopt.cc
vendored
@ -240,11 +240,11 @@ getopt_internal (int argc, char **argv, char *shortopts,
|
|||||||
|
|
||||||
/* first, is it a long option? */
|
/* first, is it a long option? */
|
||||||
if (longopts != NULL
|
if (longopts != NULL
|
||||||
&& (memcmp (argv[optind], "--", 2) == 0
|
&& (strncmp (argv[optind], "--", 2) == 0
|
||||||
|| (only && argv[optind][0] == '+')) && optwhere == 1)
|
|| (only && argv[optind][0] == '+')) && optwhere == 1)
|
||||||
{
|
{
|
||||||
/* handle long options */
|
/* handle long options */
|
||||||
if (memcmp (argv[optind], "--", 2) == 0)
|
if (strncmp (argv[optind], "--", 2) == 0)
|
||||||
optwhere = 2;
|
optwhere = 2;
|
||||||
longopt_match = -1;
|
longopt_match = -1;
|
||||||
possible_arg = strchr (argv[optind] + optwhere, '=');
|
possible_arg = strchr (argv[optind] + optwhere, '=');
|
||||||
@ -259,8 +259,8 @@ getopt_internal (int argc, char **argv, char *shortopts,
|
|||||||
match_chars = (possible_arg - argv[optind]) - optwhere;
|
match_chars = (possible_arg - argv[optind]) - optwhere;
|
||||||
for (optindex = 0; longopts[optindex].name != NULL; optindex++)
|
for (optindex = 0; longopts[optindex].name != NULL; optindex++)
|
||||||
{
|
{
|
||||||
if (memcmp (argv[optind] + optwhere,
|
if (strncmp (argv[optind] + optwhere,
|
||||||
longopts[optindex].name, match_chars) == 0)
|
longopts[optindex].name, match_chars) == 0)
|
||||||
{
|
{
|
||||||
/* do we have an exact match? */
|
/* do we have an exact match? */
|
||||||
if (match_chars == strlen (longopts[optindex].name))
|
if (match_chars == strlen (longopts[optindex].name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user