struct archive_string_conv *sconv, *fn_sconv;
unsigned long crc32_val;
int ret = (ARCHIVE_OK), ret2;
+ char *newptr;
+ size_t newsize;
rar = (struct rar *)(a->format->data);
return (ARCHIVE_FATAL);
}
if (rar->filename_allocated < filename_size * 2 + 2) {
- char *newptr;
- size_t newsize = filename_size * 2 + 2;
+ newsize = filename_size * 2 + 2;
newptr = realloc(rar->filename, newsize);
if (newptr == NULL) {
archive_set_error(&a->archive, ENOMEM,
rar->cursor++;
if (rar->cursor >= rar->nodes)
{
- rar->nodes++;
- if ((rar->dbo =
- realloc(rar->dbo, sizeof(*rar->dbo) * rar->nodes)) == NULL)
+ struct data_block_offsets *newdbo;
+
+ newsize = sizeof(*rar->dbo) * (rar->nodes + 1);
+ if ((newdbo = realloc(rar->dbo, newsize)) == NULL)
{
archive_set_error(&a->archive, ENOMEM, "Couldn't allocate memory.");
return (ARCHIVE_FATAL);
}
+ rar->dbo = newdbo;
+ rar->nodes++;
rar->dbo[rar->cursor].header_size = header_size;
rar->dbo[rar->cursor].start_offset = -1;
rar->dbo[rar->cursor].end_offset = -1;
return (ARCHIVE_FATAL);
}
- rar->filename_save = (char*)realloc(rar->filename_save,
- filename_size + 1);
- memcpy(rar->filename_save, rar->filename, filename_size + 1);
+ newsize = filename_size + 1;
+ if ((newptr = realloc(rar->filename_save, newsize)) == NULL)
+ {
+ archive_set_error(&a->archive, ENOMEM, "Couldn't allocate memory.");
+ return (ARCHIVE_FATAL);
+ }
+ rar->filename_save = newptr;
+ memcpy(rar->filename_save, rar->filename, newsize);
rar->filename_save_size = filename_size;
/* Set info for seeking */
}
for (xattr_i = 0; xattr_i < xattr_size;
xattr_i += strlen(xattr_names + xattr_i) + 1) {
- char *xattr_val_saved;
+ char *p;
ssize_t s;
int f;
ret = ARCHIVE_WARN;
goto exit_xattr;
}
- xattr_val_saved = xattr_val;
- xattr_val = realloc(xattr_val, s);
- if (xattr_val == NULL) {
+ p = realloc(xattr_val, s);
+ if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Failed to get metadata(xattr)");
ret = ARCHIVE_WARN;
- free(xattr_val_saved);
goto exit_xattr;
}
+ xattr_val = p;
s = fgetxattr(tmpfd, xattr_names + xattr_i, xattr_val, s, 0, 0);
if (s == -1) {
archive_set_error(&a->archive, errno,