diff options
author | Benjamin Peterson <bp@benjamin.pe> | 2017-07-04 12:02:51 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-07-05 10:58:23 -0400 |
commit | 05fb2f847aa7a7e32b674f309025b86e374986fc (patch) | |
tree | 7002f72c4d208a009519aa1938d1f61adc21a99d /src/tools/singlejar | |
parent | 9c787fac7e556db7eae5c6ddea97eab46f825c87 (diff) |
fix singlejar signedness problems
while (total_written < count) {
~~~~~~~~~~~~~~^~~~~~~
Most of these can be fixed by simply by storing the return value of
various functions in the right variable type. E.g., cen_offset32 can
naturally be stored in uin32_t rather than uint64_t.
Change-Id: I9f188ca541e4fe2587c636670807f56887e1655e
PiperOrigin-RevId: 160897953
Diffstat (limited to 'src/tools/singlejar')
-rw-r--r-- | src/tools/singlejar/combiners.cc | 2 | ||||
-rw-r--r-- | src/tools/singlejar/input_jar.cc | 10 | ||||
-rw-r--r-- | src/tools/singlejar/output_jar.cc | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/tools/singlejar/combiners.cc b/src/tools/singlejar/combiners.cc index ce08549d40..8fd2a0fdfe 100644 --- a/src/tools/singlejar/combiners.cc +++ b/src/tools/singlejar/combiners.cc @@ -146,7 +146,7 @@ bool XmlCombiner::Merge(const CDH *cdh, const LH *lh) { if (strncmp(buf, start_tag_.c_str(), start_tag_.length()) == 0) { start_offset = start_tag_.length(); } - int end = bytes_.data_size(); + uint64_t end = bytes_.data_size(); while (end >= end_tag_.length() && std::isspace(buf[end - 1])) end--; if (strncmp(buf + end - end_tag_.length(), end_tag_.c_str(), end_tag_.length()) == 0) { diff --git a/src/tools/singlejar/input_jar.cc b/src/tools/singlejar/input_jar.cc index 4a4a92c3b3..08007d5fd4 100644 --- a/src/tools/singlejar/input_jar.cc +++ b/src/tools/singlejar/input_jar.cc @@ -74,10 +74,10 @@ bool InputJar::Open(const std::string &path) { */ // First, sanity checks. - uint64_t cen_position = ecd->cen_offset32(); + uint32_t cen_position = ecd->cen_offset32(); if (!ziph::zfield_has_ext64(cen_position)) { if (!mapped_file_.mapped(mapped_file_.address(cen_position))) { - diag_warnx("%s:%d: %s is corrupt: Central Directory location 0x%" PRIx64 + diag_warnx("%s:%d: %s is corrupt: Central Directory location 0x%" PRIx32 " is invalid", __FILE__, __LINE__, path.c_str(), cen_position); mapped_file_.Close(); @@ -85,17 +85,17 @@ bool InputJar::Open(const std::string &path) { } if (mapped_file_.offset(ecd) < cen_position) { diag_warnx("%s:%d: %s is corrupt: End of Central Directory at 0x%" PRIx64 - " precedes Central Directory at 0x%" PRIx64, + " precedes Central Directory at 0x%" PRIx32, __FILE__, __LINE__, path.c_str(), mapped_file_.offset(ecd), cen_position); mapped_file_.Close(); return false; } } - uint64_t cen_size = ecd->cen_size32(); + uint32_t cen_size = ecd->cen_size32(); if (!ziph::zfield_has_ext64(cen_size)) { if (cen_size > mapped_file_.offset(ecd)) { - diag_warnx("%s:%d: %s is corrupt: Central Directory size 0x%" PRIx64 + diag_warnx("%s:%d: %s is corrupt: Central Directory size 0x%" PRIx32 " is too large", __FILE__, __LINE__, path.c_str(), cen_size); mapped_file_.Close(); diff --git a/src/tools/singlejar/output_jar.cc b/src/tools/singlejar/output_jar.cc index 80eaede63a..7fd97abb6e 100644 --- a/src/tools/singlejar/output_jar.cc +++ b/src/tools/singlejar/output_jar.cc @@ -235,7 +235,7 @@ int OutputJar::Doit(Options *options) { } // Then copy source files' contents. - for (int ix = 0; ix < options_->input_jars.size(); ++ix) { + for (size_t ix = 0; ix < options_->input_jars.size(); ++ix) { if (!AddJar(ix)) { exit(1); } @@ -646,7 +646,7 @@ void OutputJar::AppendToDirectoryBuffer(const CDH *cdh, off_t lh_pos, const Zip64ExtraField *zip64_ef = cdh->zip64_extra_field(); const int zip64_attr_count = zip64_ef == nullptr ? 0 : zip64_ef->attr_count(); const bool lh_pos_needs64 = ziph::zfield_needs_ext64(lh_pos); - size_t out_zip64_attr_count; + int out_zip64_attr_count; if (zip64_attr_count > 0) { out_zip64_attr_count = zip64_attr_count; // The number of attributes may remain the same, or it may increase or @@ -881,7 +881,7 @@ ssize_t OutputJar::AppendFile(int in_fd, off_t offset, size_t count) { } ssize_t total_written = 0; - while (total_written < count) { + while (static_cast<size_t>(total_written) < count) { size_t len = std::min(kBufferSize, count - total_written); ssize_t n_read = pread(in_fd, buffer.get(), len, offset + total_written); if (n_read > 0) { |