Download raw body.
some size_t/off_t fixes for got-index-pack
this fixes some size_t/off_t usage in got-index-pack. I've spotted these while looking into off_t/size_t usage in inflate.c, after a stsp' comment on irc. this is only a step though: there's still an implicit off_t -> size_t conversion when calling the inflate.c functions, so this change is almost a no-op effectively, but since the inflate.c diff would vely likely be bigger i thought of starting with committing this. ok? diff aabb25f81b1f8f68a03af422f9ae14ea5c3ae1fd 535672d658a448620f24cd3a0bf61e9a6a98c94c commit - aabb25f81b1f8f68a03af422f9ae14ea5c3ae1fd commit + 535672d658a448620f24cd3a0bf61e9a6a98c94c blob - be8dabb4b70569ee825b8a9571f0915a88776478 blob + 9ccb27ec5b1aa961b76fabb64c5f2e6094f9e14b --- lib/pack.c +++ lib/pack.c @@ -842,7 +842,7 @@ got_pack_parse_object_type_and_size(uint8_t *type, uin uint8_t t = 0; uint64_t s = 0; uint8_t sizeN; - size_t mapoff = 0; + off_t mapoff = 0; int i = 0; *len = 0; @@ -851,7 +851,7 @@ got_pack_parse_object_type_and_size(uint8_t *type, uin return got_error(GOT_ERR_PACK_OFFSET); if (pack->map) { - mapoff = (size_t)offset; + mapoff = offset; } else { if (lseek(pack->fd, offset, SEEK_SET) == -1) return got_error_from_errno("lseek"); @@ -928,8 +928,8 @@ parse_negative_offset(int64_t *offset, size_t *len, st return got_error(GOT_ERR_NO_SPACE); if (pack->map) { - size_t mapoff; - mapoff = (size_t)delta_offset + *len; + off_t mapoff; + mapoff = delta_offset + *len; if (mapoff + sizeof(offN) >= pack->filesize) return got_error(GOT_ERR_PACK_OFFSET); offN = *(pack->map + mapoff); @@ -1080,7 +1080,7 @@ got_pack_parse_ref_delta(struct got_object_id *id, struct got_pack *pack, off_t delta_offset, int tslen) { if (pack->map) { - size_t mapoff = delta_offset + tslen; + off_t mapoff = delta_offset + tslen; if (mapoff + sizeof(*id) >= pack->filesize) return got_error(GOT_ERR_PACK_OFFSET); memcpy(id, pack->map + mapoff, sizeof(*id)); @@ -1392,7 +1392,7 @@ got_pack_dump_delta_chain_to_file(size_t *result_size, max_size = delta->size; if (max_size > max_bufsize) { if (pack->map) { - mapoff = (size_t)delta_data_offset; + mapoff = delta_data_offset; err = got_inflate_to_file_mmap( &base_bufsz, NULL, NULL, pack->map, mapoff, pack->filesize - mapoff, @@ -1409,7 +1409,7 @@ got_pack_dump_delta_chain_to_file(size_t *result_size, } accum_bufsz = max_size; if (pack->map) { - mapoff = (size_t)delta_data_offset; + mapoff = delta_data_offset; err = got_inflate_to_mem_mmap(&base_buf, &base_bufsz, NULL, NULL, pack->map, mapoff, @@ -1586,7 +1586,7 @@ got_pack_dump_delta_chain_to_mem(uint8_t **outbuf, siz max_size = delta->size; if (pack->map) { - size_t mapoff = (size_t)delta_data_offset; + off_t mapoff = delta_data_offset; err = got_inflate_to_mem_mmap(&base_buf, &base_bufsz, NULL, NULL, pack->map, mapoff, pack->filesize - mapoff); @@ -1704,7 +1704,7 @@ got_packfile_extract_object(struct got_pack *pack, str return got_error(GOT_ERR_PACK_OFFSET); if (pack->map) { - size_t mapoff = (size_t)obj->pack_offset; + off_t mapoff = obj->pack_offset; err = got_inflate_to_file_mmap(&obj->size, NULL, NULL, pack->map, mapoff, pack->filesize - mapoff, outfile); @@ -1734,7 +1734,7 @@ got_packfile_extract_object_to_mem(uint8_t **buf, size if (obj->pack_offset >= pack->filesize) return got_error(GOT_ERR_PACK_OFFSET); if (pack->map) { - size_t mapoff = (size_t)obj->pack_offset; + off_t mapoff = obj->pack_offset; err = got_inflate_to_mem_mmap(buf, len, NULL, NULL, pack->map, mapoff, pack->filesize - mapoff); } else { blob - a361289b4a09acce2ecd03e2d8817a2f84e28f5a blob + 06f67a9876ec2cdda565b0e36e3cf14c8d503ed4 --- libexec/got-index-pack/got-index-pack.c +++ libexec/got-index-pack/got-index-pack.c @@ -184,7 +184,7 @@ read_packed_object(struct got_pack *pack, struct got_i char *header; size_t headerlen; const char *obj_label; - size_t mapoff = obj->off; + off_t mapoff = obj->off; struct got_inflate_checksum csum; memset(&csum, 0, sizeof(csum)); @@ -645,7 +645,7 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp uint8_t packidx_hash[SHA1_DIGEST_LENGTH]; ssize_t r, w; int pass, have_ref_deltas = 0, first_delta_idx = -1; - size_t mapoff = 0; + off_t mapoff = 0; int p_indexed = 0, last_p_indexed = -1; int p_resolved = 0, last_p_resolved = -1; struct got_ratelimit rl;
some size_t/off_t fixes for got-index-pack