Changeset View
Changeset View
Standalone View
Standalone View
contrib/libarchive/libarchive/archive_write_set_format_ar.c
Show First 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | archive_write_ar_data(struct archive_write *a, const void *buff, size_t s) | ||||
if (ar->is_strtab > 0) { | if (ar->is_strtab > 0) { | ||||
if (ar->has_strtab > 0) { | if (ar->has_strtab > 0) { | ||||
archive_set_error(&a->archive, EINVAL, | archive_set_error(&a->archive, EINVAL, | ||||
"More than one string tables exist"); | "More than one string tables exist"); | ||||
return (ARCHIVE_WARN); | return (ARCHIVE_WARN); | ||||
} | } | ||||
ar->strtab = (char *)malloc(s); | ar->strtab = (char *)malloc(s + 1); | ||||
if (ar->strtab == NULL) { | if (ar->strtab == NULL) { | ||||
archive_set_error(&a->archive, ENOMEM, | archive_set_error(&a->archive, ENOMEM, | ||||
"Can't allocate strtab buffer"); | "Can't allocate strtab buffer"); | ||||
return (ARCHIVE_FATAL); | return (ARCHIVE_FATAL); | ||||
} | } | ||||
strncpy(ar->strtab, buff, s); | strncpy(ar->strtab, buff, s); | ||||
ar->strtab[s] = '\0'; | |||||
ar->has_strtab = 1; | ar->has_strtab = 1; | ||||
} | } | ||||
ret = __archive_write_output(a, buff, s); | ret = __archive_write_output(a, buff, s); | ||||
if (ret != ARCHIVE_OK) | if (ret != ARCHIVE_OK) | ||||
return (ret); | return (ret); | ||||
ar->entry_bytes_remaining -= s; | ar->entry_bytes_remaining -= s; | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |