aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mac/symupload
diff options
context:
space:
mode:
authorSylvain Defresne <sdefresne@chromium.org>2016-08-09 12:43:39 -0700
committerSylvain Defresne <sdefresne@chromium.org>2016-08-09 23:13:07 +0000
commit600ec35c5b0bf503b3f437c5f378eadbc8d58601 (patch)
tree1f0317e46ebeeb4d1f86fe28ae2cf6c1fffa2261 /src/tools/mac/symupload
parentDon't define |r_debug| and |link_map| on Android releases 21 and later (diff)
downloadbreakpad-600ec35c5b0bf503b3f437c5f378eadbc8d58601.tar.xz
Fail with a proper error message if input file is not found.
Previously, if the input file was missing, the symupload tool on Mac would happily process, try to parse it (calling a method on nil) and fail when trying to create the payload to send to the server as one of the method raised a NSInvalidArgumentException when receiving a nil value. Change to code to instead check the file for existence which makes it easier to understand what is happening when part of the build system is misconfigured and invoke symupload without first creating the symbol file. BUG=449348 Change-Id: Icc0f08958114da4be0cbbd7a7c2aeef905bc0db1 Reviewed-on: https://chromium-review.googlesource.com/367260 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/tools/mac/symupload')
-rw-r--r--src/tools/mac/symupload/symupload.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/mac/symupload/symupload.m b/src/tools/mac/symupload/symupload.m
index 179f8d50..a7cce7b0 100644
--- a/src/tools/mac/symupload/symupload.m
+++ b/src/tools/mac/symupload/symupload.m
@@ -38,6 +38,8 @@
// cpu: the CPU that the module was built for (x86 or ppc)
// symbol_file: the contents of the breakpad-format symbol file
+#include <fcntl.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <Foundation/Foundation.h>
@@ -165,6 +167,25 @@ SetupOptions(int argc, const char *argv[], Options *options) {
exit(1);
}
+ int fd = open(argv[optind], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "%s: %s: %s\n", argv[0], argv[optind], strerror(errno));
+ exit(1);
+ }
+
+ struct stat statbuf;
+ if (fstat(fd, &statbuf) < 0) {
+ fprintf(stderr, "%s: %s: %s\n", argv[0], argv[optind], strerror(errno));
+ close(fd);
+ exit(1);
+ }
+ close(fd);
+
+ if (!S_ISREG(statbuf.st_mode)) {
+ fprintf(stderr, "%s: %s: not a regular file\n", argv[0], argv[optind]);
+ exit(1);
+ }
+
options->symbolsPath = [NSString stringWithUTF8String:argv[optind]];
options->uploadURLStr = [NSString stringWithUTF8String:argv[optind + 1]];
}