summaryrefslogtreecommitdiff
path: root/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c')
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c250
1 files changed, 142 insertions, 108 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
index 0b9aaf941..e7226256b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009-2011 Michihiro NAKAJIMA
+ * Copyright (c) 2009-2012 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -994,7 +994,7 @@ static void isoent_remove_child(struct isoent *, struct isoent *);
static void isoent_setup_directory_location(struct iso9660 *,
int, struct vdd *);
static void isoent_setup_file_location(struct iso9660 *, int);
-static int get_path_component(char *, int, const char *);
+static int get_path_component(char *, size_t, const char *);
static int isoent_tree(struct archive_write *, struct isoent **);
static struct isoent *isoent_find_child(struct isoent *, const char *);
static struct isoent *isoent_find_entry(struct isoent *, const char *);
@@ -1507,6 +1507,11 @@ iso9660_options(struct archive_write *a, const char *key, const char *value)
break;
}
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+
invalid_value:
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Invalid value for option ``%s''", key);
@@ -1693,7 +1698,7 @@ wb_write_padding_to_temp(struct archive_write *a, int64_t csize)
size_t ns;
int ret;
- ns = csize % LOGICAL_BLOCK_SIZE;
+ ns = (size_t)(csize % LOGICAL_BLOCK_SIZE);
if (ns != 0)
ret = write_null(a, LOGICAL_BLOCK_SIZE - ns);
else
@@ -1720,8 +1725,8 @@ write_iso9660_data(struct archive_write *a, const void *buff, size_t s)
struct content *con;
size_t ts;
- ts = MULTI_EXTENT_SIZE - LOGICAL_BLOCK_SIZE -
- iso9660->cur_file->cur_content->size;
+ ts = (size_t)(MULTI_EXTENT_SIZE - LOGICAL_BLOCK_SIZE -
+ iso9660->cur_file->cur_content->size);
if (iso9660->zisofs.detect_magic)
zisofs_detect_magic(a, buff, ts);
@@ -1741,9 +1746,9 @@ write_iso9660_data(struct archive_write *a, const void *buff, size_t s)
return (ARCHIVE_FATAL);
/* Compute the logical block number. */
- iso9660->cur_file->cur_content->blocks =
- (iso9660->cur_file->cur_content->size
- + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS;
+ iso9660->cur_file->cur_content->blocks = (int)
+ ((iso9660->cur_file->cur_content->size
+ + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS);
/*
* Make next extent.
@@ -1791,7 +1796,7 @@ iso9660_write_data(struct archive_write *a, const void *buff, size_t s)
if (archive_entry_filetype(iso9660->cur_file->entry) != AE_IFREG)
return (0);
if (s > iso9660->bytes_remaining)
- s = iso9660->bytes_remaining;
+ s = (size_t)iso9660->bytes_remaining;
if (s == 0)
return (0);
@@ -1833,9 +1838,9 @@ iso9660_finish_entry(struct archive_write *a)
return (ARCHIVE_FATAL);
/* Compute the logical block number. */
- iso9660->cur_file->cur_content->blocks =
- (iso9660->cur_file->cur_content->size
- + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS;
+ iso9660->cur_file->cur_content->blocks = (int)
+ ((iso9660->cur_file->cur_content->size
+ + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS);
/* Add the current file to data file list. */
isofile_add_data_file(iso9660, iso9660->cur_file);
@@ -1852,7 +1857,7 @@ iso9660_close(struct archive_write *a)
iso9660 = a->format_data;
/*
- * Write remaining data out to the temprary file.
+ * Write remaining data out to the temporary file.
*/
if (wb_remaining(a) > 0) {
ret = wb_write_out(a);
@@ -1881,7 +1886,7 @@ iso9660_close(struct archive_write *a)
ret = zisofs_rewind_boot_file(a);
if (ret < 0)
return (ret);
- /* Write remaining data out to the temprary file. */
+ /* Write remaining data out to the temporary file. */
if (wb_remaining(a) > 0) {
ret = wb_write_out(a);
if (ret < 0)
@@ -2239,7 +2244,7 @@ set_str_utf16be(struct archive_write *a, unsigned char *p, const char *s,
onepad = 0;
if (vdc == VDC_UCS2) {
struct iso9660 *iso9660 = a->format_data;
- if (archive_strncpy_in_locale(&iso9660->utf16be, s, strlen(s),
+ if (archive_strncpy_l(&iso9660->utf16be, s, strlen(s),
iso9660->sconv_to_utf16be) != 0 && errno == ENOMEM) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory for UTF-16BE");
@@ -2542,7 +2547,7 @@ set_date_time(unsigned char *p, time_t t)
set_digit(p+10, 2, tm.tm_min);
set_digit(p+12, 2, tm.tm_sec);
set_digit(p+14, 2, 0);
- set_num_712(p+16, get_gmoffset(&tm)/(60*15));
+ set_num_712(p+16, (char)(get_gmoffset(&tm)/(60*15)));
}
static void
@@ -2564,7 +2569,7 @@ set_time_915(unsigned char *p, time_t t)
set_num_711(p+3, tm.tm_hour);
set_num_711(p+4, tm.tm_min);
set_num_711(p+5, tm.tm_sec);
- set_num_712(p+6, get_gmoffset(&tm)/(60*15));
+ set_num_712(p+6, (char)(get_gmoffset(&tm)/(60*15)));
}
@@ -2884,7 +2889,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
if (nmmax > 0xff)
nmmax = 0xff;
while (nmlen + 5 > nmmax) {
- length = nmmax;
+ length = (int)nmmax;
if (bp != NULL) {
bp[3] = length;
bp[5] = 0x01;/* Alternate Name continues
@@ -2907,7 +2912,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
bp[4] = 1; /* version */
}
}
- length = 5 + nmlen;
+ length = 5 + (int)nmlen;
if (bp != NULL) {
bp[3] = length;
bp[5] = 0;
@@ -2936,8 +2941,8 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
bp = extra_next_record(&ctl, length);
if (bp != NULL) {
mode_t mode;
- uid_t uid;
- gid_t gid;
+ int64_t uid;
+ int64_t gid;
mode = archive_entry_mode(file->entry);
uid = archive_entry_uid(file->entry);
@@ -2970,8 +2975,8 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
/* file links (stat.st_nlink) */
set_num_733(bp+13,
archive_entry_nlink(file->entry));
- set_num_733(bp+21, uid);
- set_num_733(bp+29, gid);
+ set_num_733(bp+21, (uint32_t)uid);
+ set_num_733(bp+29, (uint32_t)gid);
/* File Serial Number */
if (pxent->dir)
set_num_733(bp+37, pxent->dir_location);
@@ -3352,8 +3357,8 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
bp[3] = length;
bp[4] = 1; /* version */
dev = (uint64_t)archive_entry_rdev(file->entry);
- set_num_733(bp + 5, dev >> 32);
- set_num_733(bp + 13, dev & 0xFFFFFFFF);
+ set_num_733(bp + 5, (uint32_t)(dev >> 32));
+ set_num_733(bp + 13, (uint32_t)(dev & 0xFFFFFFFF));
bp += length;
}
extra_tell_used_size(&ctl, length);
@@ -3487,7 +3492,7 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent,
set_num_733(bp+11,
xisoent->dir_block * LOGICAL_BLOCK_SIZE);
else
- set_num_733(bp+11, file->cur_content->size);
+ set_num_733(bp+11, (uint32_t)file->cur_content->size);
/* Recording Date and Time */
/* NOTE:
* If a file type is symbolic link, you are seeing this
@@ -3506,7 +3511,7 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent,
/* Volume Sequence Number */
set_num_723(bp+29, iso9660->volume_sequence_number);
/* Length of File Identifier */
- set_num_711(bp+33, fi_len);
+ set_num_711(bp+33, (unsigned char)fi_len);
/* File Identifier */
switch (t) {
case DIR_REC_VD:
@@ -3537,20 +3542,20 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent,
if (t == DIR_REC_VD) {
if (p != NULL)
/* Length of Directory Record */
- set_num_711(p, dr_len);
+ set_num_711(p, (unsigned char)dr_len);
else
- isoent->dr_len.vd = dr_len;
- return (dr_len);
+ isoent->dr_len.vd = (int)dr_len;
+ return ((int)dr_len);
}
/* Rockridge */
if (iso9660->opt.rr && vdd_type != VDD_JOLIET)
- dr_len = set_directory_record_rr(bp, dr_len,
+ dr_len = set_directory_record_rr(bp, (int)dr_len,
isoent, iso9660, t);
if (p != NULL)
/* Length of Directory Record */
- set_num_711(p, dr_len);
+ set_num_711(p, (unsigned char)dr_len);
else {
/*
* Save the size which is needed to write this
@@ -3563,15 +3568,15 @@ set_directory_record(unsigned char *p, size_t n, struct isoent *isoent,
* in switch .... */
break;
case DIR_REC_SELF:
- isoent->dr_len.self = dr_len; break;
+ isoent->dr_len.self = (int)dr_len; break;
case DIR_REC_PARENT:
- isoent->dr_len.parent = dr_len; break;
+ isoent->dr_len.parent = (int)dr_len; break;
case DIR_REC_NORMAL:
- isoent->dr_len.normal = dr_len; break;
+ isoent->dr_len.normal = (int)dr_len; break;
}
}
- return (dr_len);
+ return ((int)dr_len);
}
/*
@@ -3664,7 +3669,7 @@ wb_set_offset(struct archive_write *a, int64_t off)
iso9660->wbuff_tail = iso9660->wbuff_offset + used;
if (iso9660->wbuff_offset < iso9660->wbuff_written) {
if (used > 0 &&
- write_to_temp(a, iso9660->wbuff, used) != ARCHIVE_OK)
+ write_to_temp(a, iso9660->wbuff, (size_t)used) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
iso9660->wbuff_offset = iso9660->wbuff_written;
lseek(iso9660->temp_fd, iso9660->wbuff_offset, SEEK_SET);
@@ -3683,13 +3688,13 @@ wb_set_offset(struct archive_write *a, int64_t off)
iso9660->wbuff_offset = off;
iso9660->wbuff_remaining = sizeof(iso9660->wbuff);
} else if (off <= iso9660->wbuff_tail) {
- iso9660->wbuff_remaining =
- sizeof(iso9660->wbuff) - (off - iso9660->wbuff_offset);
+ iso9660->wbuff_remaining = (size_t)
+ (sizeof(iso9660->wbuff) - (off - iso9660->wbuff_offset));
} else {
ext_bytes = off - iso9660->wbuff_tail;
- iso9660->wbuff_remaining = sizeof(iso9660->wbuff)
- - (iso9660->wbuff_tail - iso9660->wbuff_offset);
- while (ext_bytes >= iso9660->wbuff_remaining) {
+ iso9660->wbuff_remaining = (size_t)(sizeof(iso9660->wbuff)
+ - (iso9660->wbuff_tail - iso9660->wbuff_offset));
+ while (ext_bytes >= (int64_t)iso9660->wbuff_remaining) {
if (write_null(a, (size_t)iso9660->wbuff_remaining)
!= ARCHIVE_OK)
return (ARCHIVE_FATAL);
@@ -4250,7 +4255,7 @@ _write_path_table(struct archive_write *a, int type_m, int depth,
bp = wb -1;
}
/* Length of Directory Identifier */
- set_num_711(bp+1, len);
+ set_num_711(bp+1, (unsigned char)len);
/* Extended Attribute Record Length */
set_num_711(bp+2, 0);
/* Location of Extent */
@@ -4273,7 +4278,7 @@ _write_path_table(struct archive_write *a, int type_m, int depth,
bp[9+len] = 0;
len++;
}
- wsize += 8 + len;
+ wsize += 8 + (int)len;
bp += 8 + len;
}
if ((bp + 1) > wb) {
@@ -4508,8 +4513,7 @@ write_file_descriptors(struct archive_write *a)
/* Write the boot file contents. */
if (iso9660->el_torito.boot != NULL) {
- struct isofile *file = iso9660->el_torito.boot->file;
-
+ file = iso9660->el_torito.boot->file;
blocks = file->content.blocks;
offset = file->content.offset_of_temp;
if (offset != 0) {
@@ -4810,13 +4814,19 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
struct archive_wstring ws;
if (wp != NULL) {
+ int r;
archive_string_init(&ws);
archive_wstrcpy(&ws, wp);
cleanup_backslash_2(ws.s);
archive_string_empty(&(file->parentdir));
- archive_string_append_from_wcs(&(file->parentdir),
+ r = archive_string_append_from_wcs(&(file->parentdir),
ws.s, ws.length);
archive_wstring_free(&ws);
+ if (r < 0 && errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory");
+ return (ARCHIVE_FATAL);
+ }
}
}
#endif
@@ -4919,14 +4929,20 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
struct archive_wstring ws;
if (wp != NULL) {
+ int r;
archive_string_init(&ws);
archive_wstrcpy(&ws, wp);
cleanup_backslash_2(ws.s);
archive_string_empty(&(file->symlink));
- archive_string_append_from_wcs(
+ r = archive_string_append_from_wcs(
&(file->symlink),
ws.s, ws.length);
archive_wstring_free(&ws);
+ if (r < 0 && errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory");
+ return (ARCHIVE_FATAL);
+ }
}
}
#endif
@@ -5422,8 +5438,8 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location)
iso9660->total_file_block = 0;
if ((isoent = iso9660->el_torito.catalog) != NULL) {
isoent->file->content.location = location;
- block = (archive_entry_size(isoent->file->entry) +
- LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS;
+ block = (int)((archive_entry_size(isoent->file->entry) +
+ LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS);
location += block;
iso9660->total_file_block += block;
}
@@ -5431,8 +5447,9 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location)
isoent->file->content.location = location;
size = fd_boot_image_size(iso9660->el_torito.media_type);
if (size == 0)
- size = archive_entry_size(isoent->file->entry);
- block = (size + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS;
+ size = (size_t)archive_entry_size(isoent->file->entry);
+ block = ((int)size + LOGICAL_BLOCK_SIZE -1)
+ >> LOGICAL_BLOCK_BITS;
location += block;
iso9660->total_file_block += block;
isoent->file->content.blocks = block;
@@ -5493,10 +5510,10 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location)
}
static int
-get_path_component(char *name, int n, const char *fn)
+get_path_component(char *name, size_t n, const char *fn)
{
char *p;
- int l;
+ size_t l;
p = strchr(fn, '/');
if (p == NULL) {
@@ -5509,7 +5526,7 @@ get_path_component(char *name, int n, const char *fn)
memcpy(name, fn, l);
name[l] = '\0';
- return (l);
+ return ((int)l);
}
/*
@@ -5802,17 +5819,18 @@ idr_ensure_poolsize(struct archive_write *a, struct idr *idr,
{
if (idr->pool_size < cnt) {
+ void *p;
const int bk = (1 << 7) - 1;
int psize;
psize = (cnt + bk) & ~bk;
- idr->idrent_pool = realloc(idr->idrent_pool,
- sizeof(struct idrent) * psize);
- if (idr->idrent_pool == NULL) {
+ p = realloc(idr->idrent_pool, sizeof(struct idrent) * psize);
+ if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory");
return (ARCHIVE_FATAL);
}
+ idr->idrent_pool = (struct idrent *)p;
idr->pool_size = psize;
}
return (ARCHIVE_OK);
@@ -6000,7 +6018,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
char *dot, *xdot;
int ext_off, noff, weight;
- l = np->file->basename.length;
+ l = (int)np->file->basename.length;
p = malloc(l+31+2+1);
if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
@@ -6064,7 +6082,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
ext_off = l;
} else {
*dot = '.';
- ext_off = dot - p;
+ ext_off = (int)(dot - p);
if (iso9660->opt.iso_level == 1) {
if (dot - p <= 8) {
@@ -6091,11 +6109,11 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
ext_off = dnmax;
}
} else if (l > ffmax) {
- int extlen = strlen(dot);
+ int extlen = (int)strlen(dot);
int xdoff;
if (xdot != NULL)
- xdoff = xdot - p;
+ xdoff = (int)(xdot - p);
else
xdoff = 0;
@@ -6132,7 +6150,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
}
/* Save an offset of a file name extension to sort files. */
np->ext_off = ext_off;
- np->ext_len = strlen(&p[ext_off]);
+ np->ext_len = (int)strlen(&p[ext_off]);
np->id_len = l = ext_off + np->ext_len;
/* Make an offset of the number which is used to be set
@@ -6249,30 +6267,35 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
p += 2;
lt -= 2;
}
- ext_off = dot - (unsigned char *)np->identifier;
+ ext_off = (int)(dot - (unsigned char *)np->identifier);
np->ext_off = ext_off;
- np->ext_len = l - ext_off;
- np->id_len = l;
+ np->ext_len = (int)l - ext_off;
+ np->id_len = (int)l;
/*
* Get a length of MBS of a full-pathname.
*/
if ((int)np->file->basename_utf16.length > ffmax) {
- archive_strncpy_in_locale(&iso9660->mbs,
+ if (archive_strncpy_l(&iso9660->mbs,
(const char *)np->identifier, l,
- iso9660->sconv_from_utf16be);
- np->mb_len = iso9660->mbs.length;
+ iso9660->sconv_from_utf16be) != 0 &&
+ errno == ENOMEM) {
+ archive_set_error(&a->archive, errno,
+ "No memory");
+ return (ARCHIVE_FATAL);
+ }
+ np->mb_len = (int)iso9660->mbs.length;
if (np->mb_len != (int)np->file->basename.length)
weight = np->mb_len;
} else
- np->mb_len = np->file->basename.length;
+ np->mb_len = (int)np->file->basename.length;
/* If a length of full-pathname is longer than 240 bytes,
* it violates Joliet extensions regulation. */
if (parent_len + np->mb_len > 240) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"The regulation of Joliet extensions;"
- " A lenght of a full-pathname of `%s' is "
+ " A length of a full-pathname of `%s' is "
"longer than 240 bytes, (p=%d, b=%d)",
archive_entry_pathname(np->file->entry),
(int)parent_len, (int)np->mb_len);
@@ -6280,7 +6303,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
}
/* Make an offset of the number which is used to be set
- * hexadecimal number to avoid duplicate identififier. */
+ * hexadecimal number to avoid duplicate identifier. */
if ((int)l == ffmax)
noff = ext_off - 6;
else if ((int)l == ffmax-2)
@@ -6300,7 +6323,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
}
/*
- * This comparing rule is acording to ISO9660 Standard 9.3
+ * This comparing rule is according to ISO9660 Standard 9.3
*/
static int
isoent_cmp_iso9660_identifier(const struct isoent *p1, const struct isoent *p2)
@@ -6360,7 +6383,7 @@ isoent_cmp_iso9660_identifier(const struct isoent *p1, const struct isoent *p2)
if (0x20 != *s2++)
return (0x20
- *(const unsigned char *)(s2 - 1));
- } else if (p1->ext_len < p2->ext_len) {
+ } else if (p1->ext_len > p2->ext_len) {
s1 += l;
l = p1->ext_len - p2->ext_len;
while (l--)
@@ -6448,7 +6471,7 @@ isoent_cmp_joliet_identifier(const struct isoent *p1, const struct isoent *p2)
while (l--)
if (0 != *s2++)
return (- *(const unsigned char *)(s2 - 1));
- } else if (p1->ext_len < p2->ext_len) {
+ } else if (p1->ext_len > p2->ext_len) {
s1 += l;
l = p1->ext_len - p2->ext_len;
while (l--)
@@ -6514,8 +6537,7 @@ isoent_traverse_tree(struct archive_write *a, struct vdd* vdd)
struct idr idr;
int depth;
int r;
- int (*genid)(struct archive_write *a, struct isoent *isoent,
- struct idr *idr);
+ int (*genid)(struct archive_write *, struct isoent *, struct idr *);
idr_init(iso9660, vdd, &idr);
np = vdd->rootent;
@@ -6896,12 +6918,22 @@ isoent_make_path_table_2(struct archive_write *a, struct vdd *vdd,
switch (vdd->vdd_type) {
case VDD_PRIMARY:
case VDD_ENHANCED:
+#ifdef __COMPAR_FN_T
+ qsort(enttbl, pt->cnt, sizeof(struct isoent *),
+ (__compar_fn_t)_compare_path_table);
+#else
qsort(enttbl, pt->cnt, sizeof(struct isoent *),
_compare_path_table);
+#endif
break;
case VDD_JOLIET:
+#ifdef __COMPAR_FN_T
+ qsort(enttbl, pt->cnt, sizeof(struct isoent *),
+ (__compar_fn_t)_compare_path_table_joliet);
+#else
qsort(enttbl, pt->cnt, sizeof(struct isoent *),
_compare_path_table_joliet);
+#endif
break;
}
for (i = 0; i < pt->cnt; i++)
@@ -7284,7 +7316,7 @@ setup_boot_information(struct archive_write *a)
size_t rsize;
ssize_t i, rs;
- if (size > sizeof(buff))
+ if (size > (int64_t)sizeof(buff))
rsize = sizeof(buff);
else
rsize = (size_t)size;
@@ -7370,7 +7402,7 @@ zisofs_init(struct archive_write *a, struct isofile *file)
struct iso9660 *iso9660 = a->format_data;
#ifdef HAVE_ZLIB_H
uint64_t tsize;
- size_t ceil, bpsize;
+ size_t _ceil, bpsize;
int r;
#endif
@@ -7405,12 +7437,13 @@ zisofs_init(struct archive_write *a, struct isofile *file)
/* Mark file->zisofs to create RRIP 'ZF' Use Entry. */
file->zisofs.header_size = ZF_HEADER_SIZE >> 2;
file->zisofs.log2_bs = ZF_LOG2_BS;
- file->zisofs.uncompressed_size = archive_entry_size(file->entry);
+ file->zisofs.uncompressed_size =
+ (uint32_t)archive_entry_size(file->entry);
/* Calculate a size of Block Pointers of zisofs. */
- ceil = (file->zisofs.uncompressed_size + ZF_BLOCK_SIZE -1)
+ _ceil = (file->zisofs.uncompressed_size + ZF_BLOCK_SIZE -1)
>> file->zisofs.log2_bs;
- iso9660->zisofs.block_pointers_cnt = ceil + 1;
+ iso9660->zisofs.block_pointers_cnt = (int)_ceil + 1;
iso9660->zisofs.block_pointers_idx = 0;
/* Ensure a buffer size used for Block Pointers */
@@ -7433,13 +7466,14 @@ zisofs_init(struct archive_write *a, struct isofile *file)
* file.
*/
tsize = ZF_HEADER_SIZE + bpsize;
- if (write_null(a, tsize) != ARCHIVE_OK)
+ if (write_null(a, (size_t)tsize) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
/*
* Initialize some variables to make zisofs.
*/
- archive_le32enc(&(iso9660->zisofs.block_pointers[0]), tsize);
+ archive_le32enc(&(iso9660->zisofs.block_pointers[0]),
+ (uint32_t)tsize);
iso9660->zisofs.remaining = file->zisofs.uncompressed_size;
iso9660->zisofs.making = 1;
iso9660->zisofs.allzero = 1;
@@ -7461,14 +7495,14 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
uint32_t uncompressed_size;
unsigned char header_size;
unsigned char log2_bs;
- size_t ceil, doff;
+ size_t _ceil, doff;
uint32_t bst, bed;
int magic_max;
int64_t entry_size;
entry_size = archive_entry_size(file->entry);
- if (sizeof(iso9660->zisofs.magic_buffer) > entry_size)
- magic_max = entry_size;
+ if ((int64_t)sizeof(iso9660->zisofs.magic_buffer) > entry_size)
+ magic_max = (int)entry_size;
else
magic_max = sizeof(iso9660->zisofs.magic_buffer);
@@ -7485,7 +7519,7 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
l = s;
memcpy(iso9660->zisofs.magic_buffer
+ iso9660->zisofs.magic_cnt, buff, l);
- iso9660->zisofs.magic_cnt += l;
+ iso9660->zisofs.magic_cnt += (int)l;
if (iso9660->zisofs.magic_cnt < magic_max)
return;
}
@@ -7509,16 +7543,16 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
return;/* Invalid or not supported header. */
/* Calculate a size of Block Pointers of zisofs. */
- ceil = (uncompressed_size +
+ _ceil = (uncompressed_size +
(ARCHIVE_LITERAL_LL(1) << log2_bs) -1) >> log2_bs;
- doff = (ceil + 1) * 4 + 16;
- if (entry_size < doff)
+ doff = (_ceil + 1) * 4 + 16;
+ if (entry_size < (int64_t)doff)
return;/* Invalid data. */
/* Check every Block Pointer has valid value. */
p = magic_buff + 16;
endp = magic_buff + magic_max;
- while (ceil && p + 8 <= endp) {
+ while (_ceil && p + 8 <= endp) {
bst = archive_le32dec(p);
if (bst != doff)
return;/* Invalid data. */
@@ -7527,7 +7561,7 @@ zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)
if (bed < bst || bed > entry_size)
return;/* Invalid data. */
doff += bed - bst;
- ceil--;
+ _ceil--;
}
file->zisofs.uncompressed_size = uncompressed_size;
@@ -7555,7 +7589,7 @@ zisofs_write_to_temp(struct archive_write *a, const void *buff, size_t s)
zstrm = &(iso9660->zisofs.stream);
zstrm->next_out = wb_buffptr(a);
- zstrm->avail_out = wb_remaining(a);
+ zstrm->avail_out = (uInt)wb_remaining(a);
b = (const unsigned char *)buff;
do {
avail = ZF_BLOCK_SIZE - zstrm->total_in;
@@ -7569,7 +7603,7 @@ zisofs_write_to_temp(struct archive_write *a, const void *buff, size_t s)
flush = Z_FINISH;
zstrm->next_in = (Bytef *)(uintptr_t)(const void *)b;
- zstrm->avail_in = avail;
+ zstrm->avail_in = (uInt)avail;
/*
* Check if current data block are all zero.
@@ -7625,7 +7659,7 @@ zisofs_write_to_temp(struct archive_write *a, const void *buff, size_t s)
iso9660->zisofs.total_size += csize;
iso9660->cur_file->cur_content->size += csize;
zstrm->next_out = wb_buffptr(a);
- zstrm->avail_out = wb_remaining(a);
+ zstrm->avail_out = (uInt)wb_remaining(a);
break;
default:
archive_set_error(&a->archive,
@@ -7644,7 +7678,7 @@ zisofs_write_to_temp(struct archive_write *a, const void *buff, size_t s)
iso9660->zisofs.block_pointers_idx ++;
archive_le32enc(&(iso9660->zisofs.block_pointers[
iso9660->zisofs.block_pointers_idx]),
- iso9660->zisofs.total_size);
+ (uint32_t)iso9660->zisofs.total_size);
r = zisofs_init_zstream(a);
if (r != ARCHIVE_OK)
return (ARCHIVE_FATAL);
@@ -7770,13 +7804,13 @@ zisofs_extract_init(struct archive_write *a, struct zisofs_extract *zisofs,
const unsigned char *p, size_t bytes)
{
size_t avail = bytes;
- size_t ceil, xsize;
+ size_t _ceil, xsize;
/* Allocate block pointers buffer. */
- ceil = (zisofs->pz_uncompressed_size +
+ _ceil = (size_t)((zisofs->pz_uncompressed_size +
(((int64_t)1) << zisofs->pz_log2_bs) - 1)
- >> zisofs->pz_log2_bs;
- xsize = (ceil + 1) * 4;
+ >> zisofs->pz_log2_bs);
+ xsize = (_ceil + 1) * 4;
if (zisofs->block_pointers == NULL) {
size_t alloc = ((xsize >> 10) + 1) << 10;
zisofs->block_pointers = malloc(alloc);
@@ -7789,7 +7823,7 @@ zisofs_extract_init(struct archive_write *a, struct zisofs_extract *zisofs,
zisofs->block_pointers_size = xsize;
/* Allocate uncompressed data buffer. */
- zisofs->uncompressed_buffer_size = 1UL << zisofs->pz_log2_bs;
+ zisofs->uncompressed_buffer_size = (size_t)1UL << zisofs->pz_log2_bs;
/*
* Read the file header, and check the magic code of zisofs.
@@ -7859,7 +7893,7 @@ zisofs_extract(struct archive_write *a, struct zisofs_extract *zisofs,
return (rs);
if (!zisofs->initialized) {
/* We need more data. */
- zisofs->pz_offset += bytes;
+ zisofs->pz_offset += (uint32_t)bytes;
return (bytes);
}
avail = rs;
@@ -7942,9 +7976,9 @@ zisofs_extract(struct archive_write *a, struct zisofs_extract *zisofs,
if (avail > zisofs->block_avail)
zisofs->stream.avail_in = zisofs->block_avail;
else
- zisofs->stream.avail_in = avail;
+ zisofs->stream.avail_in = (uInt)avail;
zisofs->stream.next_out = wb_buffptr(a);
- zisofs->stream.avail_out = wb_remaining(a);
+ zisofs->stream.avail_out = (uInt)wb_remaining(a);
r = inflate(&zisofs->stream, 0);
switch (r) {
@@ -7957,12 +7991,12 @@ zisofs_extract(struct archive_write *a, struct zisofs_extract *zisofs,
return (ARCHIVE_FATAL);
}
avail -= zisofs->stream.next_in - p;
- zisofs->block_avail -= zisofs->stream.next_in - p;
+ zisofs->block_avail -= (uint32_t)(zisofs->stream.next_in - p);
r = wb_consume(a, wb_remaining(a) - zisofs->stream.avail_out);
if (r < 0)
return (r);
}
- zisofs->pz_offset += bytes;
+ zisofs->pz_offset += (uint32_t)bytes;
return (bytes - avail);
}
@@ -7996,7 +8030,7 @@ zisofs_rewind_boot_file(struct archive_write *a)
fd = iso9660->temp_fd;
new_offset = wb_offset(a);
read_offset = file->content.offset_of_temp;
- remaining = file->content.size;
+ remaining = (size_t)file->content.size;
if (remaining > 1024 * 32)
rbuff_size = 1024 * 32;
else