aboutsummaryrefslogtreecommitdiff
path: root/libarchive/archive_entry.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2012-07-27 08:24:12 +0000
committerMartin Matuska <mm@FreeBSD.org>2012-07-27 08:24:12 +0000
commit81418b36c02b6434acd4b8ae4cfb8c80a3742fd4 (patch)
tree4b551422581ae9a8093415e07c619e2a59ef6a7b /libarchive/archive_entry.c
parent132160f77407d2174d2bec0a8ba9c6eefc4429d7 (diff)
downloadsrc-81418b36c02b6434acd4b8ae4cfb8c80a3742fd4.tar.gz
src-81418b36c02b6434acd4b8ae4cfb8c80a3742fd4.zip
Notes
Diffstat (limited to 'libarchive/archive_entry.c')
-rw-r--r--libarchive/archive_entry.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index cbdda8a44def..b531c77d2126 100644
--- a/libarchive/archive_entry.c
+++ b/libarchive/archive_entry.c
@@ -375,8 +375,11 @@ archive_entry_fflags_text(struct archive_entry *entry)
char *p;
if (archive_mstring_get_mbs(entry->archive,
- &entry->ae_fflags_text, &f) == 0 && f != NULL)
- return (f);
+ &entry->ae_fflags_text, &f) == 0) {
+ if (f != NULL)
+ return (f);
+ } else if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
if (entry->ae_fflags_set == 0 && entry->ae_fflags_clear == 0)
return (NULL);
@@ -390,6 +393,8 @@ archive_entry_fflags_text(struct archive_entry *entry)
if (archive_mstring_get_mbs(entry->archive,
&entry->ae_fflags_text, &f) == 0)
return (f);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -405,6 +410,8 @@ archive_entry_gname(struct archive_entry *entry)
const char *p;
if (archive_mstring_get_mbs(entry->archive, &entry->ae_gname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -414,6 +421,8 @@ archive_entry_gname_w(struct archive_entry *entry)
const wchar_t *p;
if (archive_mstring_get_wcs(entry->archive, &entry->ae_gname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -428,9 +437,13 @@ const char *
archive_entry_hardlink(struct archive_entry *entry)
{
const char *p;
- if ((entry->ae_set & AE_SET_HARDLINK) && archive_mstring_get_mbs(
+ if ((entry->ae_set & AE_SET_HARDLINK) == 0)
+ return (NULL);
+ if (archive_mstring_get_mbs(
entry->archive, &entry->ae_hardlink, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -438,9 +451,13 @@ const wchar_t *
archive_entry_hardlink_w(struct archive_entry *entry)
{
const wchar_t *p;
- if ((entry->ae_set & AE_SET_HARDLINK) && archive_mstring_get_wcs(
+ if ((entry->ae_set & AE_SET_HARDLINK) == 0)
+ return (NULL);
+ if (archive_mstring_get_wcs(
entry->archive, &entry->ae_hardlink, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -511,6 +528,8 @@ archive_entry_pathname(struct archive_entry *entry)
if (archive_mstring_get_mbs(
entry->archive, &entry->ae_pathname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -521,6 +540,8 @@ archive_entry_pathname_w(struct archive_entry *entry)
if (archive_mstring_get_wcs(
entry->archive, &entry->ae_pathname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -584,6 +605,8 @@ archive_entry_sourcepath(struct archive_entry *entry)
if (archive_mstring_get_mbs(
entry->archive, &entry->ae_sourcepath, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -601,9 +624,13 @@ const char *
archive_entry_symlink(struct archive_entry *entry)
{
const char *p;
- if ((entry->ae_set & AE_SET_SYMLINK) && archive_mstring_get_mbs(
+ if ((entry->ae_set & AE_SET_SYMLINK) == 0)
+ return (NULL);
+ if (archive_mstring_get_mbs(
entry->archive, &entry->ae_symlink, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -611,9 +638,13 @@ const wchar_t *
archive_entry_symlink_w(struct archive_entry *entry)
{
const wchar_t *p;
- if ((entry->ae_set & AE_SET_SYMLINK) && archive_mstring_get_wcs(
+ if ((entry->ae_set & AE_SET_SYMLINK) == 0)
+ return (NULL);
+ if (archive_mstring_get_wcs(
entry->archive, &entry->ae_symlink, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -641,6 +672,8 @@ archive_entry_uname(struct archive_entry *entry)
const char *p;
if (archive_mstring_get_mbs(entry->archive, &entry->ae_uname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -650,6 +683,8 @@ archive_entry_uname_w(struct archive_entry *entry)
const wchar_t *p;
if (archive_mstring_get_wcs(entry->archive, &entry->ae_uname, &p) == 0)
return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
}
@@ -730,6 +765,8 @@ archive_entry_update_gname_utf8(struct archive_entry *entry, const char *name)
if (archive_mstring_update_utf8(entry->archive,
&entry->ae_gname, name) == 0)
return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (0);
}
@@ -796,6 +833,8 @@ archive_entry_update_hardlink_utf8(struct archive_entry *entry, const char *targ
if (archive_mstring_update_utf8(entry->archive,
&entry->ae_hardlink, target) == 0)
return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (0);
}
@@ -932,7 +971,11 @@ archive_entry_update_link_utf8(struct archive_entry *entry, const char *target)
else
r = archive_mstring_update_utf8(entry->archive,
&entry->ae_hardlink, target);
- return ((r == 0)? 1: 0);
+ if (r == 0)
+ return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (0);
}
int
@@ -1005,6 +1048,8 @@ archive_entry_update_pathname_utf8(struct archive_entry *entry, const char *name
if (archive_mstring_update_utf8(entry->archive,
&entry->ae_pathname, name) == 0)
return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (0);
}
@@ -1115,6 +1160,8 @@ archive_entry_update_symlink_utf8(struct archive_entry *entry, const char *linkn
if (archive_mstring_update_utf8(entry->archive,
&entry->ae_symlink, linkname) == 0)
return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (0);
}
@@ -1164,6 +1211,8 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name)
if (archive_mstring_update_utf8(entry->archive,
&entry->ae_uname, name) == 0)
return (1);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (0);
}
@@ -1269,7 +1318,12 @@ int
archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
int *permset, int *tag, int *id, const char **name)
{
- return archive_acl_next(entry->archive, &entry->acl, want_type, type, permset, tag, id, name);
+ int r;
+ r = archive_acl_next(entry->archive, &entry->acl, want_type, type,
+ permset, tag, id, name);
+ if (r == ARCHIVE_FATAL && errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (r);
}
/*
@@ -1279,7 +1333,11 @@ archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
const wchar_t *
archive_entry_acl_text_w(struct archive_entry *entry, int flags)
{
- return archive_acl_text_w(entry->archive, &entry->acl, flags);
+ const wchar_t *r;
+ r = archive_acl_text_w(entry->archive, &entry->acl, flags);
+ if (r == NULL && errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (r);
}
const char *
@@ -1288,7 +1346,7 @@ archive_entry_acl_text(struct archive_entry *entry, int flags)
const char *p;
if (archive_acl_text_l(&entry->acl, flags, &p, NULL, NULL) != 0
&& errno == ENOMEM)
- return (NULL);
+ __archive_errx(1, "No memory");
return (p);
}