aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party
diff options
context:
space:
mode:
authorGravatar Thiago Farina <tfarina@chromium.org>2016-04-05 09:30:51 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-04-05 14:09:11 +0000
commit74d179acce3434a6d0cf7d0488e22472161aca37 (patch)
tree497581f8a790e5941b50f181825034f73988e983 /third_party
parenta6ae3e7a43d32c13081886ffa64b5d14157f4910 (diff)
ijar: check the return value of getcwd() function
Check the return value of getcwd() and if it fails print a message to the user and return -1. This should fix the following warning: third_party/ijar/zip_main.cc:175:32: warning: ignoring return value of 'char* getcwd(char*, size_t)', declared with attribute warn_unused_result [-Wunused-result] getcwd(output_root, PATH_MAX); -- Change-Id: I8857e484f5baf60289d7c19a128f5a4616ae50e4 Reviewed-on: https://bazel-review.googlesource.com/#/c/3230/ MOS_MIGRATED_REVID=119029402
Diffstat (limited to 'third_party')
-rw-r--r--third_party/ijar/zip_main.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc
index 4ac13160e2..1c55ee9fdc 100644
--- a/third_party/ijar/zip_main.cc
+++ b/third_party/ijar/zip_main.cc
@@ -172,7 +172,10 @@ int copy_file_to_buffer(int fd, size_t size, void *buffer) {
// Execute the extraction (or just listing if just v is provided)
int extract(char *zipfile, bool verbose, bool extract) {
char output_root[PATH_MAX];
- getcwd(output_root, PATH_MAX);
+ if (getcwd(output_root, PATH_MAX) == NULL) {
+ fprintf(stderr, "getcwd() failed: %s.\n", strerror(errno));
+ return -1;
+ }
UnzipProcessor processor(output_root, verbose, extract);
std::unique_ptr<ZipExtractor> extractor(ZipExtractor::Create(zipfile,