summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-04-27 09:18:49 +0000
committerJakub Jelinek <jakub@redhat.com>2009-04-27 09:18:49 +0000
commit51211e710a024163f91ffd5ed29908faa3cd41e7 (patch)
treef8fd0fe6e4ce0ec25195f50d93c75f5e2c0a7dfe
parent8feaf01b210752a478e2e59a274ef244c8af2c0b (diff)
Fix up build-locale-archive.c
-rw-r--r--fedora/build-locale-archive.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fedora/build-locale-archive.c b/fedora/build-locale-archive.c
index afe0cbdaae..f68c788220 100644
--- a/fedora/build-locale-archive.c
+++ b/fedora/build-locale-archive.c
@@ -63,14 +63,6 @@ next_prime (unsigned long seed)
return seed;
}
-/* xmalloc is only used by show_archive_content. */
-void *
-xmalloc (size_t size)
-{
- (void) size;
- exit (255);
-}
-
void
error (int status, int errnum, const char *message, ...)
{
@@ -89,6 +81,15 @@ error (int status, int errnum, const char *message, ...)
exit (errnum == EROFS ? 0 : status);
}
+void *
+xmalloc (size_t size)
+{
+ void *p = malloc (size);
+ if (p == NULL)
+ error (EXIT_FAILURE, errno, "could not allocate %zd bytes of memory", size);
+ return p;
+}
+
static void
open_tmpl_archive (struct locarhandle *ah)
{
@@ -112,15 +113,16 @@ open_tmpl_archive (struct locarhandle *ah)
error (EXIT_FAILURE, errno, "cannot read archive header");
ah->fd = fd;
- ah->len = (head.sumhash_offset
- + head.sumhash_size * sizeof (struct sumhashent));
- if (ah->len > st.st_size)
+ ah->mmaped = (head.sumhash_offset
+ + head.sumhash_size * sizeof (struct sumhashent));
+ if (ah->mmaped > (unsigned long) st.st_size)
error (EXIT_FAILURE, 0, "locale archite template file truncated");
- ah->len = st.st_size;
+ ah->mmaped = st.st_size;
+ ah->reserved = st.st_size;
/* Now we know how large the administrative information part is.
Map all of it. */
- ah->addr = mmap64 (NULL, ah->len, PROT_READ, MAP_SHARED, fd, 0);
+ ah->addr = mmap64 (NULL, ah->mmaped, PROT_READ, MAP_SHARED, fd, 0);
if (ah->addr == MAP_FAILED)
error (EXIT_FAILURE, errno, "cannot map archive header");
}