- p = name;
- ret = sprintf (p, "%s", prefix);
- if (ret < 0 || (bfd_vma) ret != strlen (prefix))
+ payload_len -= namelen + bytes_read;
+ filesize = bfd_get_file_size (abfd);
+ if (filesize != 0 && namelen > filesize)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return FALSE;
+ }
+ name = bfd_alloc (abfd, namelen + prefixlen + 1);
+ if (!name)