/* BFD back-end for archive files (libraries).
- Copyright (C) 1990-2019 Free Software Foundation, Inc.
+ Copyright (C) 1990-2020 Free Software Foundation, Inc.
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
This file is part of BFD, the Binary File Descriptor library.
if (parsed_size < 4)
return FALSE;
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
+ raw_armap = (bfd_byte *) bfd_alloc (abfd, parsed_size);
if (raw_armap == NULL)
return FALSE;
bsd-style one in core all at once, for simplicity. */
if (nsymz > ~ (bfd_size_type) 0 / sizeof (carsym))
- return FALSE;
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return FALSE;
+ }
carsym_size = (nsymz * sizeof (carsym));
ptrsize = (4 * nsymz);
if (carsym_size + stringsize + 1 <= carsym_size)
- return FALSE;
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return FALSE;
+ }
- ardata->symdefs = (struct carsym *) bfd_zalloc (abfd,
- carsym_size + stringsize + 1);
+ ardata->symdefs = (struct carsym *) bfd_alloc (abfd,
+ carsym_size + stringsize + 1);
if (ardata->symdefs == NULL)
return FALSE;
carsyms = ardata->symdefs;
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
- goto release_raw_armap;
+ goto release_symdefs;
}
/* OK, build the carsyms. */
return TRUE;
-release_raw_armap:
- bfd_release (abfd, raw_armap);
release_symdefs:
bfd_release (abfd, (ardata)->symdefs);
return FALSE;
goto byebye;
bfd_ardata (abfd)->extended_names_size = amt;
- bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1);
+ bfd_ardata (abfd)->extended_names = (char *) bfd_alloc (abfd, amt + 1);
if (bfd_ardata (abfd)->extended_names == NULL)
{
byebye:
bfd_ardata (abfd)->extended_names = NULL;
goto byebye;
}
+ bfd_ardata (abfd)->extended_names[amt] = 0;
/* Since the archive is supposed to be printable if it contains
text, the entries in the list are newline-padded, not null
if (total_namelen == 0)
return TRUE;
- *tabloc = (char *) bfd_zalloc (abfd, total_namelen);
+ *tabloc = (char *) bfd_alloc (abfd, total_namelen);
if (*tabloc == NULL)
return FALSE;
stroff = last_stroff;
else
{
- strcpy (strptr, normal);
- if (! trailing_slash)
- strptr[thislen] = ARFMAG[1];
- else
- {
- strptr[thislen] = '/';
- strptr[thislen + 1] = ARFMAG[1];
- }
+ last_filename = filename;
stroff = strptr - *tabloc;
last_stroff = stroff;
+ memcpy (strptr, normal, thislen);
+ strptr += thislen;
+ if (trailing_slash)
+ *strptr++ = '/';
+ *strptr++ = ARFMAG[1];
}
hdr->ar_name[0] = ar_padchar (current);
if (bfd_is_thin_archive (abfd) && current->origin > 0)
}
else
_bfd_ar_spacepad (hdr->ar_name + 1, maxname - 1, "%-ld", stroff);
- if (normal != last_filename)
- {
- strptr += thislen + 1;
- if (trailing_slash)
- ++strptr;
- last_filename = filename;
- }
}
}