instead of use of __archive_errx().
SVN-Revision: 3156
goto invalid;
archive_string_init(&(file->pathname));
if ((file->attr & ATTR_NAME_IS_UTF) && cab->sconv == NULL) {
- if (cab->sconv_utf8 == NULL)
+ if (cab->sconv_utf8 == NULL) {
cab->sconv_utf8 =
archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (cab->sconv_utf8 == NULL)
+ return (ARCHIVE_FATAL);
+ }
archive_strncpy_in_locale(&(file->pathname), p, len,
cab->sconv_utf8);
} else
/* Convert UTF-16BE of a filename to local locale MBS and store
* the result into a filename field. */
- if (iso9660->sconv_utf16be == NULL)
+ if (iso9660->sconv_utf16be == NULL) {
iso9660->sconv_utf16be =
archive_string_conversion_from_charset(
&(a->archive), "UTF-16BE", 1);
+ if (iso9660->sconv_utf16be == NULL)
+ return (NULL);/* Coundn't allocate memory */
+ }
archive_strncpy_in_locale(&file->name,
(const char *)p, name_len, iso9660->sconv_utf16be);
} else {
lha->sconv =
archive_string_conversion_from_charset(
&(a->archive), charset, 1);
+ if (lha->sconv == NULL)
+ return (ARCHIVE_FATAL);
}
}
break;
while (*p != '\0' && p < acl + size)
p++;
- if (tar->sconv_acl == NULL)
+ if (tar->sconv_acl == NULL) {
tar->sconv_acl = archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (tar->sconv_acl == NULL)
+ return (ARCHIVE_FATAL);
+ }
if (archive_strncpy_in_locale(&(tar->localname), acl, p - acl,
tar->sconv_acl) != 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
/* Identify this attribute and set it in the entry. */
err2 = pax_attribute(a, tar, entry, key, value);
+ if (err2 == ARCHIVE_FATAL)
+ return (err2);
err = err_combine(err, err2);
/* Skip to next line */
*/
sconv = archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (sconv == NULL)
+ return (ARCHIVE_FATAL);
}
if (archive_strlen(&(tar->entry_gname)) > 0) {
case 'S':
/* We support some keys used by the "star" archiver */
if (strcmp(key, "SCHILY.acl.access")==0) {
- if (tar->sconv_acl == NULL)
+ if (tar->sconv_acl == NULL) {
tar->sconv_acl =
archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (tar->sconv_acl == NULL)
+ return (ARCHIVE_FATAL);
+ }
if (archive_strcpy_in_locale(&(tar->localname),
value, tar->sconv_acl) != 0) {
tar->localname.s,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
} else if (strcmp(key, "SCHILY.acl.default")==0) {
- if (tar->sconv_acl == NULL)
+ if (tar->sconv_acl == NULL) {
tar->sconv_acl =
archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (tar->sconv_acl == NULL)
+ return (ARCHIVE_FATAL);
+ }
if (archive_strcpy_in_locale(&(tar->localname),
value, tar->sconv_acl) != 0) {
if (xar->offset == 0) {
/* Create a character conversion object. */
- if (xar->sconv == NULL)
+ if (xar->sconv == NULL) {
xar->sconv = archive_string_conversion_from_charset(
&(a->archive), "UTF-8", 1);
+ if (xar->sconv == NULL)
+ return (ARCHIVE_FATAL);
+ }
/* Read TOC. */
r = read_toc(a);
}
if (zip->sconv == NULL && (zip->flags & ZIP_UTF8_NAME) != 0) {
/* The filename is stored to be UTF-8. */
- if (zip->sconv_utf8 == NULL)
+ if (zip->sconv_utf8 == NULL) {
zip->sconv_utf8 =
archive_string_conversion_from_charset(
&a->archive, "UTF-8", 1);
+ if (zip->sconv_utf8 == NULL)
+ return (ARCHIVE_FATAL);
+ }
if (archive_strncpy_in_locale(&zip->pathname,
h, zip->filename_length, zip->sconv_utf8) != 0) {
archive_set_error(&a->archive,
sc = malloc(sizeof(*sc));
if (sc == NULL)
- __archive_errx(1, "No memory for charset conversion object");
+ return (NULL);
sc->next = NULL;
sc->from_charset = strdup(fc);
- if (sc->from_charset == NULL)
- __archive_errx(1, "No memory for charset conversion object");
+ if (sc->from_charset == NULL) {
+ free(sc);
+ return (NULL);
+ }
sc->to_charset = strdup(tc);
- if (sc->to_charset == NULL)
- __archive_errx(1, "No memory for charset conversion object");
+ if (sc->to_charset == NULL) {
+ free(sc);
+ free(sc->from_charset);
+ return (NULL);
+ }
sc->same = (strcmp(fc, tc) == 0)?1:0;
#if HAVE_ICONV
sc->cd = iconv_open(tc, fc);
else
current_codepage = a->current_codepage;
sc = create_sconv_object(fc, tc, current_codepage, flag);
+ if (sc == NULL) {
+ archive_set_error(a, ENOMEM,
+ "Could not allocate memory for a string conversion object");
+ return (NULL);
+ }
#if HAVE_ICONV
if (sc->cd == (iconv_t)-1 && (flag & SCONV_BEST_EFFORT) == 0) {
free_sconv_object(sc);
* Return NULL if the platform does not support the specified conversion
* and best_effort is 0.
* If best_effort is set, A string conversion object must be returned
- * but the conversion might fail when non-ASCII code is found.
+ * except memory allocation for the object fails, but the conversion
+ * might fail when non-ASCII code is found.
*/
struct archive_string_conv *
archive_string_conversion_to_charset(struct archive *a, const char *charset,
if (aes->aes_set & AES_SET_MBS) {
sc = archive_string_conversion_to_charset(a, "UTF-8", 1);
+ if (sc == NULL)
+ return (NULL);/* Couldn't allocate memory for sc. */
r = archive_strncpy_in_locale(&(aes->aes_mbs), aes->aes_mbs.s,
aes->aes_mbs.length, sc);
if (a == NULL)
/* If there's a UTF-8 form, try converting with the native locale. */
if (aes->aes_set & AES_SET_UTF8) {
sc = archive_string_conversion_from_charset(a, "UTF-8", 1);
+ if (sc == NULL)
+ return (NULL);/* Couldn't allocate memory for sc. */
r = archive_strncpy_in_locale(&(aes->aes_mbs),
aes->aes_utf8.s, aes->aes_utf8.length, sc);
if (a == NULL)
/* Try converting UTF-8 to MBS, return false on failure. */
sc = archive_string_conversion_from_charset(a, "UTF-8", 1);
+ if (sc == NULL)
+ return (0);/* Couldn't allocate memory for sc. */
r = archive_strcpy_in_locale(&(aes->aes_mbs), utf8, sc);
if (a == NULL)
free_sconv_object(sc);
iso9660->sconv_to_utf16be =
archive_string_conversion_to_charset(
&(a->archive), "UTF-16BE", 1);
+ if (iso9660->sconv_to_utf16be == NULL)
+ return (ARCHIVE_FATAL);/* Couldn't allocate memory */
iso9660->sconv_from_utf16be =
archive_string_conversion_from_charset(
&(a->archive), "UTF-16BE", 1);
+ if (iso9660->sconv_from_utf16be == NULL)
+ return (ARCHIVE_FATAL);/* Couldn't allocate memory */
}
/* Test whether a filename can be converted to UTF-16BE or not. */
if (0 > archive_strncpy_in_locale(&iso9660->utf16be,
iso9660->sconv_to_utf16be =
archive_string_conversion_to_charset(
&(a->archive), "UTF-16BE", 1);
+ if (iso9660->sconv_to_utf16be == NULL)
+ return (ARCHIVE_FATAL);/* Couldn't allocate memory */
iso9660->sconv_from_utf16be =
archive_string_conversion_from_charset(
&(a->archive), "UTF-16BE", 1);
+ if (iso9660->sconv_from_utf16be == NULL)
+ return (ARCHIVE_FATAL);/* Couldn't allocate memory */
}
}
return (ARCHIVE_FAILED);
}
- if (pax->sconv_utf8 == NULL)
+ if (pax->sconv_utf8 == NULL) {
pax->sconv_utf8 = archive_string_conversion_to_charset(
&(a->archive), "UTF-8", 1);
+ if (pax->sconv_utf8 == NULL)
+ return (ARCHIVE_FAILED);/* Couldn't allocate memory */
+ }
/*
* Choose a header encoding.
*/