diff options
Diffstat (limited to 'libqpdf')
41 files changed, 221 insertions, 162 deletions
diff --git a/libqpdf/BitWriter.cc b/libqpdf/BitWriter.cc index 5b3051d9..441501cb 100644 --- a/libqpdf/BitWriter.cc +++ b/libqpdf/BitWriter.cc @@ -12,7 +12,7 @@ BitWriter::BitWriter(Pipeline* pl) : } void -BitWriter::writeBits(unsigned long val, int bits) +BitWriter::writeBits(unsigned long val, unsigned int bits) { write_bits(this->ch, this->bit_offset, val, bits, this->pl); } diff --git a/libqpdf/Buffer.cc b/libqpdf/Buffer.cc index 71e219a1..94e69a56 100644 --- a/libqpdf/Buffer.cc +++ b/libqpdf/Buffer.cc @@ -7,12 +7,12 @@ Buffer::Buffer() init(0, 0, true); } -Buffer::Buffer(unsigned long size) +Buffer::Buffer(size_t size) { init(size, 0, true); } -Buffer::Buffer(unsigned char* buf, unsigned long size) +Buffer::Buffer(unsigned char* buf, size_t size) { init(size, buf, false); } @@ -36,7 +36,7 @@ Buffer::~Buffer() } void -Buffer::init(unsigned long size, unsigned char* buf, bool own_memory) +Buffer::init(size_t size, unsigned char* buf, bool own_memory) { this->own_memory = own_memory; this->size = size; @@ -75,7 +75,7 @@ Buffer::destroy() this->buf = 0; } -unsigned long +size_t Buffer::getSize() const { return this->size; diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc index f00dbe4b..70be696d 100644 --- a/libqpdf/MD5.cc +++ b/libqpdf/MD5.cc @@ -308,7 +308,7 @@ void MD5::reset() void MD5::encodeString(char const* str) { - unsigned int len = strlen(str); + unsigned int len = (unsigned int)strlen(str); update((unsigned char *)str, len); final(); @@ -316,7 +316,7 @@ void MD5::encodeString(char const* str) void MD5::appendString(char const* input_string) { - update((unsigned char *)input_string, strlen(input_string)); + update((unsigned char *)input_string, (unsigned int) strlen(input_string)); } void MD5::encodeDataIncrementally(char const* data, int len) @@ -332,7 +332,7 @@ void MD5::encodeFile(char const *filename, int up_to_size) std::string("MD5: open ") + filename, fopen(filename, "rb")); - int len; + size_t len; int so_far = 0; int to_try = 1024; do @@ -344,7 +344,7 @@ void MD5::encodeFile(char const *filename, int up_to_size) len = fread(buffer, 1, to_try, file); if (len > 0) { - update(buffer, len); + update(buffer, (unsigned int) len); so_far += len; if ((up_to_size >= 0) && (so_far >= up_to_size)) { diff --git a/libqpdf/PCRE.cc b/libqpdf/PCRE.cc index 2e808aa7..1e5585b0 100644 --- a/libqpdf/PCRE.cc +++ b/libqpdf/PCRE.cc @@ -166,7 +166,7 @@ PCRE::match(char const* subject, int options, int startoffset, int size) { if (size == -1) { - size = strlen(subject); + size = (int) strlen(subject); } Match result(this->nbackrefs, subject); diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc index a43d7e69..0f73c09c 100644 --- a/libqpdf/Pl_AES_PDF.cc +++ b/libqpdf/Pl_AES_PDF.cc @@ -60,9 +60,9 @@ Pl_AES_PDF::useStaticIV() } void -Pl_AES_PDF::write(unsigned char* data, int len) +Pl_AES_PDF::write(unsigned char* data, size_t len) { - unsigned int bytes_left = len; + size_t bytes_left = len; unsigned char* p = data; while (bytes_left > 0) @@ -72,8 +72,8 @@ Pl_AES_PDF::write(unsigned char* data, int len) flush(false); } - unsigned int available = this->buf_size - this->offset; - int bytes = (bytes_left < available ? bytes_left : available); + size_t available = this->buf_size - this->offset; + size_t bytes = (bytes_left < available ? bytes_left : available); bytes_left -= bytes; std::memcpy(this->inbuf + this->offset, p, bytes); this->offset += bytes; @@ -93,7 +93,7 @@ Pl_AES_PDF::finish() // Pad as described in section 3.5.1 of version 1.7 of the PDF // specification, including providing an entire block of padding // if the input was a multiple of 16 bytes. - unsigned char pad = this->buf_size - this->offset; + unsigned char pad = (unsigned char) (this->buf_size - this->offset); memset(this->inbuf + this->offset, pad, pad); this->offset = this->buf_size; flush(false); diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc index ed73ff09..5c9c9f56 100644 --- a/libqpdf/Pl_ASCII85Decoder.cc +++ b/libqpdf/Pl_ASCII85Decoder.cc @@ -16,13 +16,13 @@ Pl_ASCII85Decoder::~Pl_ASCII85Decoder() } void -Pl_ASCII85Decoder::write(unsigned char* buf, int len) +Pl_ASCII85Decoder::write(unsigned char* buf, size_t len) { if (eod > 1) { return; } - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) { if (eod > 1) { diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc index 83f7376f..ca153e89 100644 --- a/libqpdf/Pl_ASCIIHexDecoder.cc +++ b/libqpdf/Pl_ASCIIHexDecoder.cc @@ -17,13 +17,13 @@ Pl_ASCIIHexDecoder::~Pl_ASCIIHexDecoder() } void -Pl_ASCIIHexDecoder::write(unsigned char* buf, int len) +Pl_ASCIIHexDecoder::write(unsigned char* buf, size_t len) { if (this->eod) { return; } - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) { char ch = toupper(buf[i]); switch (ch) diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc index 38af153d..600ee7de 100644 --- a/libqpdf/Pl_Buffer.cc +++ b/libqpdf/Pl_Buffer.cc @@ -15,7 +15,7 @@ Pl_Buffer::~Pl_Buffer() } void -Pl_Buffer::write(unsigned char* buf, int len) +Pl_Buffer::write(unsigned char* buf, size_t len) { Buffer* b = new Buffer(len); memcpy(b->getBuffer(), buf, len); diff --git a/libqpdf/Pl_Count.cc b/libqpdf/Pl_Count.cc index c682b3e7..78516343 100644 --- a/libqpdf/Pl_Count.cc +++ b/libqpdf/Pl_Count.cc @@ -12,7 +12,7 @@ Pl_Count::~Pl_Count() } void -Pl_Count::write(unsigned char* buf, int len) +Pl_Count::write(unsigned char* buf, size_t len) { if (len) { @@ -28,7 +28,7 @@ Pl_Count::finish() getNext()->finish(); } -int +off_t Pl_Count::getCount() const { return this->count; diff --git a/libqpdf/Pl_Discard.cc b/libqpdf/Pl_Discard.cc index 7b9407a1..34d49f3a 100644 --- a/libqpdf/Pl_Discard.cc +++ b/libqpdf/Pl_Discard.cc @@ -12,7 +12,7 @@ Pl_Discard::~Pl_Discard() } void -Pl_Discard::write(unsigned char* buf, int len) +Pl_Discard::write(unsigned char* buf, size_t len) { } diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc index d166e9ab..30616707 100644 --- a/libqpdf/Pl_Flate.cc +++ b/libqpdf/Pl_Flate.cc @@ -40,7 +40,7 @@ Pl_Flate::~Pl_Flate() } void -Pl_Flate::write(unsigned char* data, int len) +Pl_Flate::write(unsigned char* data, size_t len) { if (this->outbuf == 0) { @@ -48,7 +48,19 @@ Pl_Flate::write(unsigned char* data, int len) this->identifier + ": Pl_Flate: write() called after finish() called"); } - handleData(data, len, Z_NO_FLUSH); + + // Write in chunks in case len is too big to fit in an int. + // Assume int is at least 32 bits. + static size_t const max_bytes = 1 << 30; + size_t bytes_left = len; + unsigned char* buf = data; + while (bytes_left > 0) + { + size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); + handleData(buf, (int)bytes, Z_NO_FLUSH); + bytes_left -= bytes; + buf += bytes; + } } void diff --git a/libqpdf/Pl_LZWDecoder.cc b/libqpdf/Pl_LZWDecoder.cc index 811415bc..646e45de 100644 --- a/libqpdf/Pl_LZWDecoder.cc +++ b/libqpdf/Pl_LZWDecoder.cc @@ -25,9 +25,9 @@ Pl_LZWDecoder::~Pl_LZWDecoder() } void -Pl_LZWDecoder::write(unsigned char* bytes, int len) +Pl_LZWDecoder::write(unsigned char* bytes, size_t len) { - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) { this->buf[next++] = bytes[i]; if (this->next == 3) @@ -131,7 +131,7 @@ Pl_LZWDecoder::addToTable(unsigned char next) assert(idx < table.size()); Buffer& b = table[idx]; last_data = b.getBuffer(); - last_size = b.getSize(); + last_size = (unsigned int) b.getSize(); } Buffer entry(1 + last_size); @@ -170,7 +170,7 @@ Pl_LZWDecoder::handleCode(int code) // be what we read last plus the first character of what // we're reading now. unsigned char next = '\0'; - unsigned int table_size = table.size(); + unsigned int table_size = (unsigned int) table.size(); if (code < 256) { // just read < 256; last time's next was code @@ -178,7 +178,7 @@ Pl_LZWDecoder::handleCode(int code) } else if (code > 257) { - unsigned int idx = code - 258; + size_t idx = code - 258; if (idx > table_size) { throw std::runtime_error("LZWDecoder: bad code received"); diff --git a/libqpdf/Pl_MD5.cc b/libqpdf/Pl_MD5.cc index 29787625..44911b42 100644 --- a/libqpdf/Pl_MD5.cc +++ b/libqpdf/Pl_MD5.cc @@ -12,14 +12,27 @@ Pl_MD5::~Pl_MD5() } void -Pl_MD5::write(unsigned char* buf, int len) +Pl_MD5::write(unsigned char* buf, size_t len) { if (! this->in_progress) { this->md5.reset(); this->in_progress = true; } - this->md5.encodeDataIncrementally((char*) buf, len); + + // Write in chunks in case len is too big to fit in an int. + // Assume int is at least 32 bits. + static size_t const max_bytes = 1 << 30; + size_t bytes_left = len; + unsigned char* data = buf; + while (bytes_left > 0) + { + size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); + this->md5.encodeDataIncrementally((char*) data, (int)bytes); + bytes_left -= bytes; + data += bytes; + } + this->getNext()->write(buf, len); } diff --git a/libqpdf/Pl_PNGFilter.cc b/libqpdf/Pl_PNGFilter.cc index bbe10c93..19b90c03 100644 --- a/libqpdf/Pl_PNGFilter.cc +++ b/libqpdf/Pl_PNGFilter.cc @@ -29,10 +29,10 @@ Pl_PNGFilter::~Pl_PNGFilter() } void -Pl_PNGFilter::write(unsigned char* data, int len) +Pl_PNGFilter::write(unsigned char* data, size_t len) { - int left = this->incoming - this->pos; - unsigned int offset = 0; + size_t left = this->incoming - this->pos; + size_t offset = 0; while (len >= left) { // finish off current row diff --git a/libqpdf/Pl_QPDFTokenizer.cc b/libqpdf/Pl_QPDFTokenizer.cc index 3bd3fb6c..ea13fb72 100644 --- a/libqpdf/Pl_QPDFTokenizer.cc +++ b/libqpdf/Pl_QPDFTokenizer.cc @@ -22,7 +22,7 @@ Pl_QPDFTokenizer::~Pl_QPDFTokenizer() } void -Pl_QPDFTokenizer::writeNext(char const* buf, int len) +Pl_QPDFTokenizer::writeNext(char const* buf, size_t len) { if (len) { @@ -159,10 +159,10 @@ Pl_QPDFTokenizer::checkUnread() } void -Pl_QPDFTokenizer::write(unsigned char* buf, int len) +Pl_QPDFTokenizer::write(unsigned char* buf, size_t len) { checkUnread(); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) { processChar(buf[i]); checkUnread(); diff --git a/libqpdf/Pl_RC4.cc b/libqpdf/Pl_RC4.cc index f98c8744..74bb16b9 100644 --- a/libqpdf/Pl_RC4.cc +++ b/libqpdf/Pl_RC4.cc @@ -3,7 +3,7 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, unsigned char const* key_data, int key_len, - int out_bufsize) : + size_t out_bufsize) : Pipeline(identifier, next), out_bufsize(out_bufsize), rc4(key_data, key_len) @@ -21,7 +21,7 @@ Pl_RC4::~Pl_RC4() } void -Pl_RC4::write(unsigned char* data, int len) +Pl_RC4::write(unsigned char* data, size_t len) { if (this->outbuf == 0) { @@ -30,14 +30,15 @@ Pl_RC4::write(unsigned char* data, int len) ": Pl_RC4: write() called after finish() called"); } - int bytes_left = len; + size_t bytes_left = len; unsigned char* p = data; while (bytes_left > 0) { - int bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize); + size_t bytes = + (bytes_left < this->out_bufsize ? bytes_left : out_bufsize); bytes_left -= bytes; - rc4.process(p, bytes, outbuf); + rc4.process(p, (int)bytes, outbuf); p += bytes; getNext()->write(outbuf, bytes); } diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc index bca4d4e8..e87de10c 100644 --- a/libqpdf/Pl_StdioFile.cc +++ b/libqpdf/Pl_StdioFile.cc @@ -14,7 +14,7 @@ Pl_StdioFile::~Pl_StdioFile() } void -Pl_StdioFile::write(unsigned char* buf, int len) +Pl_StdioFile::write(unsigned char* buf, size_t len) { size_t so_far = 0; while (len > 0) diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index e1a5a688..7ed00c98 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -117,7 +117,7 @@ QPDF::FileInputSource::getName() const off_t QPDF::FileInputSource::tell() { - return ftell(this->file); + return QUtil::ftell_off_t(this->file); } void @@ -126,7 +126,7 @@ QPDF::FileInputSource::seek(off_t offset, int whence) QUtil::os_wrapper(std::string("seek to ") + this->filename + ", offset " + QUtil::int_to_string(offset) + " (" + QUtil::int_to_string(whence) + ")", - fseek(this->file, offset, whence)); + QUtil::fseek_off_t(this->file, offset, whence)); } void @@ -136,9 +136,9 @@ QPDF::FileInputSource::rewind() } size_t -QPDF::FileInputSource::read(char* buffer, int length) +QPDF::FileInputSource::read(char* buffer, size_t length) { - this->last_offset = ftell(this->file); + this->last_offset = QUtil::ftell_off_t(this->file); size_t len = fread(buffer, 1, length, this->file); if ((len == 0) && ferror(this->file)) { @@ -197,7 +197,7 @@ QPDF::BufferInputSource::seek(off_t offset, int whence) break; case SEEK_END: - this->cur_offset = this->buf->getSize() + offset; + this->cur_offset = (off_t)this->buf->getSize() + offset; break; case SEEK_CUR: @@ -218,9 +218,9 @@ QPDF::BufferInputSource::rewind() } size_t -QPDF::BufferInputSource::read(char* buffer, int length) +QPDF::BufferInputSource::read(char* buffer, size_t length) { - off_t end_pos = this->buf->getSize(); + off_t end_pos = (off_t) this->buf->getSize(); if (this->cur_offset >= end_pos) { this->last_offset = end_pos; @@ -228,7 +228,7 @@ QPDF::BufferInputSource::read(char* buffer, int length) } this->last_offset = this->cur_offset; - size_t len = std::min((int)(end_pos - this->cur_offset), length); + size_t len = std::min((size_t)(end_pos - this->cur_offset), length); memcpy(buffer, buf->getBuffer() + this->cur_offset, len); this->cur_offset += len; return len; @@ -432,7 +432,7 @@ QPDF::parse(char const* password) throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(), "", 0, "can't find startxref"); } - off_t xref_offset = atoi(m2.getMatch(1).c_str()); + off_t xref_offset = atol(m2.getMatch(1).c_str()); read_xref(xref_offset); } catch (QPDFExc& e) @@ -878,10 +878,10 @@ QPDF::processXRefStream(off_t xref_offset, QPDFObjectHandle& xref_obj) entry_size += W[i]; } - int expected_size = entry_size * num_entries; + size_t expected_size = entry_size * num_entries; PointerHolder<Buffer> bp = xref_obj.getStreamData(); - int actual_size = bp->getSize(); + size_t actual_size = bp->getSize(); if (expected_size != actual_size) { @@ -1396,7 +1396,7 @@ QPDF::readObjectInternal(PointerHolder<InputSource> input, // objects since resolving a previously unresolved // indirect object will change file position. off_t stream_offset = input->tell(); - int length = 0; + size_t length = 0; try { @@ -1419,7 +1419,7 @@ QPDF::readObjectInternal(PointerHolder<InputSource> input, } length = length_obj.getIntValue(); - input->seek(stream_offset + length, SEEK_SET); + input->seek(stream_offset + (off_t)length, SEEK_SET); if (! (readToken(input) == QPDFTokenizer::Token( QPDFTokenizer::tt_word, "endstream"))) @@ -1457,7 +1457,7 @@ QPDF::readObjectInternal(PointerHolder<InputSource> input, return object; } -int +size_t QPDF::recoverStreamLength(PointerHolder<InputSource> input, int objid, int generation, off_t stream_offset) { @@ -1474,7 +1474,7 @@ QPDF::recoverStreamLength(PointerHolder<InputSource> input, input->seek(stream_offset, SEEK_SET); std::string last_line; off_t last_line_offset = 0; - int length = 0; + size_t length = 0; while (input->tell() < eof) { std::string line = input->readLine(); diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 8567eef9..55f1bf6f 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -604,7 +604,7 @@ QPDFObjectHandle::newDictionary( QPDFObjectHandle QPDFObjectHandle::newStream(QPDF* qpdf, int objid, int generation, QPDFObjectHandle stream_dict, - off_t offset, int length) + off_t offset, size_t length) { return QPDFObjectHandle(new QPDF_Stream( qpdf, objid, generation, diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index caf02df4..a60e8605 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -175,7 +175,7 @@ QPDFTokenizer::presentCharacter(char ch) string_ignoring_newline = false; } - unsigned int bs_num_count = strlen(bs_num_register); + size_t bs_num_count = strlen(bs_num_register); bool ch_is_octal = ((ch >= '0') && (ch <= '7')); if ((bs_num_count == 3) || ((bs_num_count > 0) && (! ch_is_octal))) { diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 95fba4e0..832b3c86 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -651,7 +651,7 @@ QPDFWriter::popPipelineStack(PointerHolder<Buffer>* bp) } void -QPDFWriter::adjustAESStreamLength(unsigned long& length) +QPDFWriter::adjustAESStreamLength(size_t& length) { if (this->encrypted && (! this->cur_data_key.empty()) && this->encrypt_use_aes) @@ -679,7 +679,7 @@ QPDFWriter::pushEncryptionFilter() { p = new Pl_RC4("rc4 stream encryption", this->pipeline, (unsigned char*) this->cur_data_key.c_str(), - this->cur_data_key.length()); + (int)this->cur_data_key.length()); } pushPipeline(p); } @@ -879,9 +879,9 @@ QPDFWriter::writeTrailer(trailer_e which, int size, bool xref_stream, int prev) if (which == t_lin_first) { writeString(" /Prev "); - int pos = this->pipeline->getCount(); + off_t pos = this->pipeline->getCount(); writeString(QUtil::int_to_string(prev)); - int nspaces = pos + 11 - this->pipeline->getCount(); + int nspaces = (int)(pos - this->pipeline->getCount() + 11); assert(nspaces >= 0); writePad(nspaces); } @@ -926,7 +926,8 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, void QPDFWriter::unparseObject(QPDFObjectHandle object, int level, - unsigned int flags, int stream_length, bool compress) + unsigned int flags, size_t stream_length, + bool compress) { unsigned int child_flags = flags & ~f_stream; @@ -1137,16 +1138,16 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, Buffer* buf = bufpl.getBuffer(); val = QPDF_String( std::string((char*)buf->getBuffer(), - (size_t)buf->getSize())).unparse(true); + buf->getSize())).unparse(true); delete buf; } else { char* tmp = QUtil::copy_string(val); - unsigned int vlen = val.length(); + size_t vlen = val.length(); RC4 rc4((unsigned char const*)this->cur_data_key.c_str(), - this->cur_data_key.length()); - rc4.process((unsigned char*)tmp, vlen); + (int)this->cur_data_key.length()); + rc4.process((unsigned char*)tmp, (int)vlen); val = QPDF_String(std::string(tmp, vlen)).unparse(); delete [] tmp; } @@ -1164,7 +1165,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, } void -QPDFWriter::writeObjectStreamOffsets(std::vector<int>& offsets, +QPDFWriter::writeObjectStreamOffsets(std::vector<off_t>& offsets, int first_obj) { for (unsigned int i = 0; i < offsets.size(); ++i) @@ -1190,8 +1191,8 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) int old_id = object.getObjectID(); int new_id = obj_renumber[old_id]; - std::vector<int> offsets; - int first = 0; + std::vector<off_t> offsets; + off_t first = 0; // Generate stream itself. We have to do this in two passes so we // can calculate offsets in the first pass. @@ -1209,7 +1210,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) // Adjust offsets to skip over comment before first object first = offsets[0]; - for (std::vector<int>::iterator iter = offsets.begin(); + for (std::vector<off_t>::iterator iter = offsets.begin(); iter != offsets.end(); ++iter) { *iter -= first; @@ -1280,7 +1281,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) writeStringQDF("\n "); writeString(" /Type /ObjStm"); writeStringQDF("\n "); - unsigned long length = stream_buffer->getSize(); + size_t length = stream_buffer->getSize(); adjustAESStreamLength(length); writeString(" /Length " + QUtil::int_to_string(length)); writeStringQDF("\n "); @@ -1523,8 +1524,9 @@ QPDFWriter::generateObjectStreams() // This code doesn't do anything with /Extends. std::vector<int> const& eligible = this->pdf.getCompressibleObjects(); - unsigned int n_object_streams = (eligible.size() + 99) / 100; - unsigned int n_per = eligible.size() / n_object_streams; + unsigned int n_object_streams = + (unsigned int)((eligible.size() + 99) / 100); + unsigned int n_per = (unsigned int)(eligible.size() / n_object_streams); if (n_per * n_object_streams < eligible.size()) { ++n_per; @@ -1777,7 +1779,7 @@ QPDFWriter::writeHintStream(int hint_id) openObject(hint_id); setDataKey(hint_id); - unsigned long hlen = hint_buffer->getSize(); + size_t hlen = hint_buffer->getSize(); writeString("<< /Filter /FlateDecode /S "); writeString(QUtil::int_to_string(S)); @@ -1817,13 +1819,13 @@ QPDFWriter::writeXRefTable(trailer_e which, int first, int last, int size) int QPDFWriter::writeXRefTable(trailer_e which, int first, int last, int size, int prev, bool suppress_offsets, - int hint_id, int hint_offset, int hint_length) + int hint_id, off_t hint_offset, off_t hint_length) { writeString("xref\n"); writeString(QUtil::int_to_string(first)); writeString(" "); writeString(QUtil::int_to_string(last - first + 1)); - int space_before_zero = this->pipeline->getCount(); + off_t space_before_zero = this->pipeline->getCount(); writeString("\n"); for (int i = first; i <= last; ++i) { @@ -1865,10 +1867,10 @@ int QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset, trailer_e which, int first, int last, int size, int prev, int hint_id, - int hint_offset, int hint_length, + off_t hint_offset, off_t hint_length, bool skip_compression) { - int xref_offset = this->pipeline->getCount(); + off_t xref_offset = this->pipeline->getCount(); int space_before_zero = xref_offset - 1; // field 1 contains offsets and object stream identifiers @@ -2021,7 +2023,8 @@ QPDFWriter::writeLinearized() // // Second half objects - int second_half_uncompressed = part7.size() + part8.size() + part9.size(); + int second_half_uncompressed = + (int)(part7.size() + part8.size() + part9.size()); int second_half_first_obj = 1; int after_second_half = 1 + second_half_uncompressed; this->next_objid = after_second_half; @@ -2077,13 +2080,13 @@ QPDFWriter::writeLinearized() int part4_end_marker = part4.back().getObjectID(); int part6_end_marker = part6.back().getObjectID(); - int space_before_zero = 0; - int file_size = 0; - int part6_end_offset = 0; - int first_half_max_obj_offset = 0; - int second_xref_offset = 0; - int first_xref_end = 0; - int second_xref_end = 0; + off_t space_before_zero = 0; + off_t file_size = 0; + off_t part6_end_offset = 0; + off_t first_half_max_obj_offset = 0; + off_t second_xref_offset = 0; + off_t first_xref_end = 0; + off_t second_xref_end = 0; this->next_objid = part4_first_obj; enqueuePart(part4); @@ -2097,7 +2100,7 @@ QPDFWriter::writeLinearized() enqueuePart(part9); assert(this->next_objid == after_second_half); - int hint_length = 0; + off_t hint_length = 0; PointerHolder<Buffer> hint_buffer; // Write file in two passes. Part numbers refer to PDF spec 1.4. @@ -2118,14 +2121,14 @@ QPDFWriter::writeLinearized() // space if all numerical values in the parameter dictionary // are 10 digits long plus a few extra characters for safety. - int pos = this->pipeline->getCount(); + off_t pos = this->pipeline->getCount(); openObject(lindict_id); writeString("<<"); if (pass == 2) { std::vector<QPDFObjectHandle> const& pages = pdf.getAllPages(); int first_page_object = obj_renumber[pages[0].getObjectID()]; - int npages = pages.size(); + int npages = (int)pages.size(); writeString(" /Linearized 1 /L "); writeString(QUtil::int_to_string(file_size + hint_length)); @@ -2147,15 +2150,15 @@ QPDFWriter::writeLinearized() writeString(" >>"); closeObject(lindict_id); static int const pad = 150; - int spaces = (pos + pad - this->pipeline->getCount()); + int spaces = (pos - this->pipeline->getCount() + pad); assert(spaces >= 0); writePad(spaces); writeString("\n"); // Part 3: first page cross reference table and trailer. - int first_xref_offset = this->pipeline->getCount(); - int hint_offset = 0; + off_t first_xref_offset = this->pipeline->getCount(); + off_t hint_offset = 0; if (pass == 2) { hint_offset = this->xref[hint_id].getOffset(); @@ -2183,7 +2186,7 @@ QPDFWriter::writeLinearized() hint_length + second_xref_offset, hint_id, hint_offset, hint_length, (pass == 1)); - int endpos = this->pipeline->getCount(); + off_t endpos = this->pipeline->getCount(); if (pass == 1) { // Pad so we have enough room for the real xref @@ -2260,7 +2263,7 @@ QPDFWriter::writeLinearized() t_lin_second, 0, second_half_end, second_trailer_size, 0, 0, 0, 0, (pass == 1)); - int endpos = this->pipeline->getCount(); + off_t endpos = this->pipeline->getCount(); if (pass == 1) { @@ -2274,14 +2277,14 @@ QPDFWriter::writeLinearized() else { // Make the file size the same. - int pos = this->pipeline->getCount(); + off_t pos = this->pipeline->getCount(); writePad(second_xref_end + hint_length - 1 - pos); writeString("\n"); // If this assertion fails, maybe we didn't have // enough padding above. assert(this->pipeline->getCount() == - second_xref_end + hint_length); + (off_t)(second_xref_end + hint_length)); } } else @@ -2309,7 +2312,7 @@ QPDFWriter::writeLinearized() activatePipelineStack(); writeHintStream(hint_id); popPipelineStack(&hint_buffer); - hint_length = hint_buffer->getSize(); + hint_length = (off_t)hint_buffer->getSize(); // Restore hint offset this->xref[hint_id] = QPDFXRefEntry(1, hint_offset, 0); diff --git a/libqpdf/QPDFXRefEntry.cc b/libqpdf/QPDFXRefEntry.cc index 9a08c829..dea3aab6 100644 --- a/libqpdf/QPDFXRefEntry.cc +++ b/libqpdf/QPDFXRefEntry.cc @@ -9,7 +9,7 @@ QPDFXRefEntry::QPDFXRefEntry() : { } -QPDFXRefEntry::QPDFXRefEntry(int type, int field1, int field2) : +QPDFXRefEntry::QPDFXRefEntry(int type, off_t field1, int field2) : type(type), field1(field1), field2(field2) @@ -27,7 +27,7 @@ QPDFXRefEntry::getType() const return this->type; } -int +off_t QPDFXRefEntry::getOffset() const { if (this->type != 1) @@ -46,7 +46,7 @@ QPDFXRefEntry::getObjStreamNumber() const throw std::logic_error( "getObjStreamNumber called for xref entry of type != 2"); } - return this->field1; + return (int) this->field1; } int diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index ab61f307..def219dd 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -37,7 +37,7 @@ QPDF_Array::unparse() int QPDF_Array::getNItems() const { - return this->items.size(); + return (int)this->items.size(); } QPDFObjectHandle diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index dc8c7f93..dc6692bb 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -22,7 +22,7 @@ std::map<std::string, std::string> QPDF_Stream::filter_abbreviations; QPDF_Stream::QPDF_Stream(QPDF* qpdf, int objid, int generation, QPDFObjectHandle stream_dict, - off_t offset, int length) : + off_t offset, size_t length) : qpdf(qpdf), objid(objid), generation(generation), @@ -379,8 +379,8 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool filter, Pl_Count count("stream provider count", pipeline); this->stream_provider->provideStreamData( this->objid, this->generation, &count); - size_t actual_length = count.getCount(); - size_t desired_length = + off_t actual_length = count.getCount(); + off_t desired_length = this->stream_dict.getKey("/Length").getIntValue(); if (actual_length == desired_length) { @@ -446,5 +446,5 @@ QPDF_Stream::replaceFilterData(QPDFObjectHandle const& filter, this->stream_dict.replaceOrRemoveKey("/Filter", filter); this->stream_dict.replaceOrRemoveKey("/DecodeParms", decode_parms); this->stream_dict.replaceKey("/Length", - QPDFObjectHandle::newInteger(length)); + QPDFObjectHandle::newInteger((int)length)); } diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc index 274b2375..2ac2ed32 100644 --- a/libqpdf/QPDF_String.cc +++ b/libqpdf/QPDF_String.cc @@ -157,7 +157,7 @@ std::string QPDF_String::getUTF8Val() const { std::string result; - unsigned int len = this->val.length(); + size_t len = this->val.length(); if ((len >= 2) && (len % 2 == 0) && (this->val[0] == '\xfe') && (this->val[1] == '\xff')) { diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index 15acf067..ee5d5685 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -29,7 +29,7 @@ static unsigned int const key_bytes = 32; void pad_or_truncate_password(std::string const& password, char k1[key_bytes]) { - int password_bytes = std::min((size_t) key_bytes, password.length()); + int password_bytes = std::min(key_bytes, (unsigned int)password.length()); int pad_bytes = key_bytes - password_bytes; memcpy(k1, password.c_str(), password_bytes); memcpy(k1 + password_bytes, padding_string, pad_bytes); @@ -121,7 +121,7 @@ QPDF::compute_data_key(std::string const& encryption_key, } MD5 md5; - md5.encodeDataIncrementally(result.c_str(), result.length()); + md5.encodeDataIncrementally(result.c_str(), (int)result.length()); MD5::Digest digest; md5.digest(digest); return std::string((char*) digest, @@ -144,7 +144,7 @@ QPDF::compute_encryption_key( pbytes[2] = (char) ((data.P >> 16) & 0xff); pbytes[3] = (char) ((data.P >> 24) & 0xff); md5.encodeDataIncrementally(pbytes, 4); - md5.encodeDataIncrementally(data.id1.c_str(), data.id1.length()); + md5.encodeDataIncrementally(data.id1.c_str(), (int)data.id1.length()); if ((data.R >= 4) && (! data.encrypt_metadata)) { char bytes[4]; @@ -218,7 +218,7 @@ compute_U_value_R3(std::string const& user_password, MD5 md5; md5.encodeDataIncrementally( pad_or_truncate_password("").c_str(), key_bytes); - md5.encodeDataIncrementally(data.id1.c_str(), data.id1.length()); + md5.encodeDataIncrementally(data.id1.c_str(), (int)data.id1.length()); MD5::Digest digest; md5.digest(digest); iterate_rc4(digest, sizeof(MD5::Digest), @@ -583,16 +583,16 @@ QPDF::decryptString(std::string& str, int objid, int generation) pl.write((unsigned char*)str.c_str(), str.length()); pl.finish(); PointerHolder<Buffer> buf = bufpl.getBuffer(); - str = std::string((char*)buf->getBuffer(), (size_t)buf->getSize()); + str = std::string((char*)buf->getBuffer(), buf->getSize()); } else { QTC::TC("qpdf", "QPDF_encryption rc4 decode string"); - unsigned int vlen = str.length(); + unsigned int vlen = (int)str.length(); // Using PointerHolder guarantees that tmp will // be freed even if rc4.process throws an exception. PointerHolder<char> tmp(true, QUtil::copy_string(str)); - RC4 rc4((unsigned char const*)key.c_str(), key.length()); + RC4 rc4((unsigned char const*)key.c_str(), (int)key.length()); rc4.process((unsigned char*)tmp.getPointer(), vlen); str = std::string(tmp.getPointer(), vlen); } @@ -704,7 +704,7 @@ QPDF::decryptStream(Pipeline*& pipeline, int objid, int generation, { QTC::TC("qpdf", "QPDF_encryption rc4 decode stream"); pipeline = new Pl_RC4("RC4 stream decryption", pipeline, - (unsigned char*) key.c_str(), key.length()); + (unsigned char*) key.c_str(), (int)key.length()); } heap.push_back(pipeline); } diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 9891890f..d4e98dde 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -289,7 +289,7 @@ QPDF::readLinearizationData() PointerHolder<Buffer> hbp = pb.getBuffer(); Buffer* hb = hbp.getPointer(); unsigned char const* h_buf = hb->getBuffer(); - int h_size = hb->getSize(); + int h_size = (int)hb->getSize(); readHPageOffset(BitStream(h_buf, h_size)); @@ -345,7 +345,7 @@ QPDF::readHintStream(Pipeline& pl, off_t offset, size_t length) { QTC::TC("qpdf", "QPDF hint table length direct"); } - off_t computed_end = offset + length; + off_t computed_end = offset + (off_t)length; if ((computed_end < min_end_offset) || (computed_end > max_end_offset)) { @@ -488,7 +488,7 @@ QPDF::checkLinearizationInternal() } // N: number of pages - int npages = pages.size(); + int npages = (int)pages.size(); if (p.npages != npages) { // Not tested in the test suite @@ -736,7 +736,7 @@ QPDF::checkHPageOffset(std::list<std::string>& errors, // under a page's /Resources dictionary in with shared objects // even when they are private. - unsigned int npages = pages.size(); + unsigned int npages = (unsigned int)pages.size(); int table_offset = adjusted_offset( this->page_offset_hints.first_page_offset); ObjGen first_page_og(pages[0].getObjectID(), pages[0].getGeneration()); @@ -1425,7 +1425,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) pages.push_back(getUncompressedObject(*iter, object_stream_data)); } } - unsigned int npages = pages.size(); + unsigned int npages = (unsigned int)pages.size(); // We will be initializing some values of the computed hint // tables. Specifically, we can initialize any items that deal @@ -1495,7 +1495,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) // in garbage values for all the shared object identifiers on the // first page. - this->c_page_offset_data.entries[0].nobjects = this->part6.size(); + this->c_page_offset_data.entries[0].nobjects = (int)this->part6.size(); // Part 7: other pages' private objects @@ -1646,9 +1646,11 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) // Make sure we got everything exactly once. - unsigned int num_placed = this->part4.size() + this->part6.size() + - this->part7.size() + this->part8.size() + this->part9.size(); - unsigned int num_wanted = this->object_to_obj_users.size(); + unsigned int num_placed = + (unsigned int)(this->part4.size() + this->part6.size() + + this->part7.size() + this->part8.size() + + this->part9.size()); + unsigned int num_wanted = (unsigned int)this->object_to_obj_users.size(); if (num_placed != num_wanted) { throw std::logic_error( @@ -1672,10 +1674,11 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) // can map from object number only without regards to generation. std::map<int, int> obj_to_index; - this->c_shared_object_data.nshared_first_page = this->part6.size(); + this->c_shared_object_data.nshared_first_page = + (unsigned int)this->part6.size(); this->c_shared_object_data.nshared_total = this->c_shared_object_data.nshared_first_page + - this->part8.size(); + (unsigned int) this->part8.size(); std::vector<CHSharedObjectEntry>& shared = this->c_shared_object_data.entries; @@ -1684,7 +1687,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) { QPDFObjectHandle& oh = *iter; int obj = oh.getObjectID(); - obj_to_index[obj] = shared.size(); + obj_to_index[obj] = (int)shared.size(); shared.push_back(CHSharedObjectEntry(obj)); } QTC::TC("qpdf", "QPDF lin part 8 empty", this->part8.empty() ? 1 : 0); @@ -1698,7 +1701,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data) { QPDFObjectHandle& oh = *iter; int obj = oh.getObjectID(); - obj_to_index[obj] = shared.size(); + obj_to_index[obj] = (int)shared.size(); shared.push_back(CHSharedObjectEntry(obj)); } } @@ -1814,7 +1817,7 @@ QPDF::calculateHPageOffset( // values. std::vector<QPDFObjectHandle> const& pages = getAllPages(); - unsigned int npages = pages.size(); + unsigned int npages = (unsigned int)pages.size(); CHPageOffset& cph = this->c_page_offset_data; std::vector<CHPageOffsetEntry>& cphe = cph.entries; @@ -2019,7 +2022,7 @@ QPDF::writeHPageOffset(BitWriter& w) w.writeBits(t.nbits_shared_numerator, 16); // 12 w.writeBits(t.shared_denominator, 16); // 13 - unsigned int nitems = getAllPages().size(); + unsigned int nitems = (unsigned int)getAllPages().size(); std::vector<HPageOffsetEntry>& entries = t.entries; write_vector_int(w, nitems, entries, @@ -2110,12 +2113,12 @@ QPDF::generateHintStream(std::map<int, QPDFXRefEntry> const& xref, BitWriter w(&c); writeHPageOffset(w); - S = c.getCount(); + S = (int)c.getCount(); writeHSharedObject(w); O = 0; if (this->outline_hints.nobjects > 0) { - O = c.getCount(); + O = (int)c.getCount(); writeHGeneric(w, this->outline_hints); } c.finish(); diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 1bdae0fe..e1071940 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1,4 +1,5 @@ #include <qpdf/QUtil.hh> +#include <qpdf/qpdf-config.h> #include <stdio.h> #include <errno.h> #include <ctype.h> @@ -14,7 +15,7 @@ #endif std::string -QUtil::int_to_string(int num, int fullpad) +QUtil::int_to_string(long long num, int fullpad) { // This routine will need to be recompiled if an int can be longer than // 49 digits. @@ -28,14 +29,20 @@ QUtil::int_to_string(int num, int fullpad) "limit"); } +#ifdef HAVE_PRINTF_LL +# define PRINTF_LL "ll" +#else +# define PRINTF_LL "l" +#endif if (fullpad) { - sprintf(t, "%0*d", fullpad, num); + sprintf(t, "%0*" PRINTF_LL "d", fullpad, num); } else { - sprintf(t, "%d", num); + sprintf(t, "%" PRINTF_LL "d", num); } +#undef PRINTF_LL return std::string(t); } @@ -101,6 +108,26 @@ QUtil::fopen_wrapper(std::string const& description, FILE* f) return f; } +int +QUtil::fseek_off_t(FILE* stream, off_t offset, int whence) +{ +#if HAVE_FSEEKO + return fseeko(stream, offset, whence); +#else + return fseek(stream, offset, whence); +#endif +} + +off_t +QUtil::ftell_off_t(FILE* stream) +{ +#if HAVE_FSEEKO + return ftello(stream); +#else + return ftell(stream); +#endif +} + char* QUtil::copy_string(std::string const& str) { diff --git a/libqpdf/RC4.cc b/libqpdf/RC4.cc index c51ebacd..b992937f 100644 --- a/libqpdf/RC4.cc +++ b/libqpdf/RC4.cc @@ -15,7 +15,7 @@ RC4::RC4(unsigned char const* key_data, int key_len) { if (key_len == -1) { - key_len = strlen((char*)key_data); + key_len = (int)strlen((char*)key_data); } for (int i = 0; i < 256; ++i) diff --git a/libqpdf/bits.icc b/libqpdf/bits.icc index e6abdf0e..31765986 100644 --- a/libqpdf/bits.icc +++ b/libqpdf/bits.icc @@ -95,7 +95,7 @@ read_bits(unsigned char const*& p, unsigned int& bit_offset, #ifdef BITS_WRITE static void write_bits(unsigned char& ch, unsigned int& bit_offset, - unsigned long val, unsigned bits, Pipeline* pipeline) + unsigned long val, unsigned int bits, Pipeline* pipeline) { if (bits > 32) { diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index 784351bc..2be301bb 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -462,10 +462,10 @@ static void qpdf_get_buffer_internal(qpdf_data qpdf) } } -unsigned long qpdf_get_buffer_length(qpdf_data qpdf) +size_t qpdf_get_buffer_length(qpdf_data qpdf) { qpdf_get_buffer_internal(qpdf); - unsigned long result = 0L; + size_t result = 0; if (qpdf->output_buffer) { result = qpdf->output_buffer->getSize(); diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh index 3ca05e10..5eae398f 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -15,7 +15,7 @@ class BitWriter QPDF_DLL BitWriter(Pipeline* pl); QPDF_DLL - void writeBits(unsigned long val, int bits); + void writeBits(unsigned long val, unsigned int bits); // Force any partial byte to be written to the pipeline. QPDF_DLL void flush(); diff --git a/libqpdf/qpdf/Pl_AES_PDF.hh b/libqpdf/qpdf/Pl_AES_PDF.hh index 178ea1e1..3947506b 100644 --- a/libqpdf/qpdf/Pl_AES_PDF.hh +++ b/libqpdf/qpdf/Pl_AES_PDF.hh @@ -22,7 +22,7 @@ class Pl_AES_PDF: public Pipeline virtual ~Pl_AES_PDF(); QPDF_DLL - virtual void write(unsigned char* data, int len); + virtual void write(unsigned char* data, size_t len); QPDF_DLL virtual void finish(); @@ -43,7 +43,7 @@ class Pl_AES_PDF: public Pipeline bool encrypt; bool cbc_mode; bool first; - unsigned int offset; + size_t offset; // offset into memory buffer unsigned char key[key_size]; uint32_t rk[key_size + 28]; unsigned char inbuf[buf_size]; diff --git a/libqpdf/qpdf/Pl_ASCII85Decoder.hh b/libqpdf/qpdf/Pl_ASCII85Decoder.hh index 333e370c..001da867 100644 --- a/libqpdf/qpdf/Pl_ASCII85Decoder.hh +++ b/libqpdf/qpdf/Pl_ASCII85Decoder.hh @@ -11,7 +11,7 @@ class Pl_ASCII85Decoder: public Pipeline QPDF_DLL virtual ~Pl_ASCII85Decoder(); QPDF_DLL - virtual void write(unsigned char* buf, int len); + virtual void write(unsigned char* buf, size_t len); QPDF_DLL virtual void finish(); @@ -19,8 +19,8 @@ class Pl_ASCII85Decoder: public Pipeline void flush(); char inbuf[5]; - int pos; - int eod; + size_t pos; + size_t eod; }; #endif // __PL_ASCII85DECODER_HH__ diff --git a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh index 12808dc8..1d33afde 100644 --- a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh +++ b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh @@ -11,7 +11,7 @@ class Pl_ASCIIHexDecoder: public Pipeline QPDF_DLL virtual ~Pl_ASCIIHexDecoder(); QPDF_DLL - virtual void write(unsigned char* buf, int len); + virtual void write(unsigned char* buf, size_t len); QPDF_DLL virtual void finish(); @@ -19,7 +19,7 @@ class Pl_ASCIIHexDecoder: public Pipeline void flush(); char inbuf[3]; - int pos; + size_t pos; bool eod; }; diff --git a/libqpdf/qpdf/Pl_LZWDecoder.hh b/libqpdf/qpdf/Pl_LZWDecoder.hh index b74d69e2..4121f6f2 100644 --- a/libqpdf/qpdf/Pl_LZWDecoder.hh +++ b/libqpdf/qpdf/Pl_LZWDecoder.hh @@ -15,7 +15,7 @@ class Pl_LZWDecoder: public Pipeline QPDF_DLL virtual ~Pl_LZWDecoder(); QPDF_DLL - virtual void write(unsigned char* buf, int len); + virtual void write(unsigned char* buf, size_t len); QPDF_DLL virtual void finish(); diff --git a/libqpdf/qpdf/Pl_MD5.hh b/libqpdf/qpdf/Pl_MD5.hh index 28c9f87d..13a0927d 100644 --- a/libqpdf/qpdf/Pl_MD5.hh +++ b/libqpdf/qpdf/Pl_MD5.hh @@ -20,7 +20,7 @@ class Pl_MD5: public Pipeline QPDF_DLL virtual ~Pl_MD5(); QPDF_DLL - virtual void write(unsigned char*, int); + virtual void write(unsigned char*, size_t); QPDF_DLL virtual void finish(); QPDF_DLL diff --git a/libqpdf/qpdf/Pl_PNGFilter.hh b/libqpdf/qpdf/Pl_PNGFilter.hh index d7c761bd..7d7ebe76 100644 --- a/libqpdf/qpdf/Pl_PNGFilter.hh +++ b/libqpdf/qpdf/Pl_PNGFilter.hh @@ -30,7 +30,7 @@ class Pl_PNGFilter: public Pipeline virtual ~Pl_PNGFilter(); QPDF_DLL - virtual void write(unsigned char* data, int len); + virtual void write(unsigned char* data, size_t len); QPDF_DLL virtual void finish(); @@ -45,8 +45,8 @@ class Pl_PNGFilter: public Pipeline unsigned char* prev_row; unsigned char* buf1; unsigned char* buf2; - int pos; - int incoming; + size_t pos; + size_t incoming; }; #endif // __PL_PNGFILTER_HH__ diff --git a/libqpdf/qpdf/Pl_QPDFTokenizer.hh b/libqpdf/qpdf/Pl_QPDFTokenizer.hh index 3f816f5d..0d041577 100644 --- a/libqpdf/qpdf/Pl_QPDFTokenizer.hh +++ b/libqpdf/qpdf/Pl_QPDFTokenizer.hh @@ -18,13 +18,13 @@ class Pl_QPDFTokenizer: public Pipeline public: Pl_QPDFTokenizer(char const* identifier, Pipeline* next); virtual ~Pl_QPDFTokenizer(); - virtual void write(unsigned char* buf, int len); + virtual void write(unsigned char* buf, size_t len); virtual void finish(); private: void processChar(char ch); void checkUnread(); - void writeNext(char const*, int len); + void writeNext(char const*, size_t len); void writeToken(QPDFTokenizer::Token&); QPDFTokenizer tokenizer; diff --git a/libqpdf/qpdf/Pl_RC4.hh b/libqpdf/qpdf/Pl_RC4.hh index 1a7c94ea..bb892f12 100644 --- a/libqpdf/qpdf/Pl_RC4.hh +++ b/libqpdf/qpdf/Pl_RC4.hh @@ -14,18 +14,18 @@ class Pl_RC4: public Pipeline QPDF_DLL Pl_RC4(char const* identifier, Pipeline* next, unsigned char const* key_data, int key_len = -1, - int out_bufsize = def_bufsize); + size_t out_bufsize = def_bufsize); QPDF_DLL virtual ~Pl_RC4(); QPDF_DLL - virtual void write(unsigned char* data, int len); + virtual void write(unsigned char* data, size_t len); QPDF_DLL virtual void finish(); private: unsigned char* outbuf; - int out_bufsize; + size_t out_bufsize; RC4 rc4; }; diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh index 144a9274..f6886b62 100644 --- a/libqpdf/qpdf/QPDF_Stream.hh +++ b/libqpdf/qpdf/QPDF_Stream.hh @@ -13,7 +13,7 @@ class QPDF_Stream: public QPDFObject public: QPDF_Stream(QPDF*, int objid, int generation, QPDFObjectHandle stream_dict, - off_t offset, int length); + off_t offset, size_t length); virtual ~QPDF_Stream(); virtual std::string unparse(); QPDFObjectHandle getDict() const; @@ -51,7 +51,7 @@ class QPDF_Stream: public QPDFObject int generation; QPDFObjectHandle stream_dict; off_t offset; - int length; + size_t length; PointerHolder<Buffer> stream_data; PointerHolder<QPDFObjectHandle::StreamDataProvider> stream_provider; }; |