aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Moss <mmoss@google.com>2020-06-04 23:28:44 +0000
committerNelson Billing <nbilling@google.com>2020-06-05 01:31:45 +0000
commit2757a2c9c819fcae3784576aef0c8400c7ad06d7 (patch)
treedb3eb4400e3481586bfabec9075d3aebbfee8d1b /src
parentAvoid calling demangler for non-C++ symbols on Linux (diff)
downloadbreakpad-2757a2c9c819fcae3784576aef0c8400c7ad06d7.tar.xz
Make symupload exit with an error code when command-line parsing fails.
This should address the issue where some Chrome builds were failing to upload symbols due to a bad command-line flag, but there was no indication of a problem, and no build failure, because symupload was exiting with a success code. BUG=1091387 R=nbilling@google.com, wuwang@google.com Change-Id: I0d7f1a6d689ca5fd37be3abad4c5ebc97f108e50 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2231574 Reviewed-by: Nelson Billing <nbilling@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/tools/linux/symupload/sym_upload.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/tools/linux/symupload/sym_upload.cc
index f155eb95..256f73c5 100644
--- a/src/tools/linux/symupload/sym_upload.cc
+++ b/src/tools/linux/symupload/sym_upload.cc
@@ -111,7 +111,7 @@ Usage(int argc, const char *argv[]) {
//=============================================================================
static void
SetupOptions(int argc, const char *argv[], Options *options) {
- extern int optind;
+ extern int optind, optopt;
int ch;
constexpr char flag_pattern[] = "u:v:x:p:k:t:c:i:hf?";
@@ -120,7 +120,11 @@ SetupOptions(int argc, const char *argv[], Options *options) {
case 'h':
case '?':
Usage(argc, argv);
- exit(0);
+ // ch might be '?' because getopt found an error while parsing args (as
+ // opposed to finding "-?" as an arg), in which case optopt is set to
+ // the bad arg value, so return an error code if optopt is set,
+ // otherwise exit cleanly.
+ exit(optopt == 0 ? 0 : 1);
break;
case 'u':
options->proxy_user_pwd = optarg;