Fixed a bug which could have caused a crash if pspp were presented
with a corrupt zip file.
- ds_put_format (zm->errs, _("Cannot initialize inflator: %s"), zError (r));
+ ds_put_format (zm->errmsgs, _("Cannot initialize inflator: %s"), zError (r));
return n - inf->zss.avail_out;
}
return n - inf->zss.avail_out;
}
- ds_put_format (zm->errs, _("Error inflating: %s"), zError (r));
+ ds_put_format (zm->errmsgs, _("Error inflating: %s"), zError (r));
comp_code (struct zip_member *zm, uint16_t c)
{
enum compression which;
comp_code (struct zip_member *zm, uint16_t c)
{
enum compression which;
which = COMPRESSION_INFLATE;
break;
default:
which = COMPRESSION_INFLATE;
break;
default:
- ds_put_format (zm->errs, _("Unsupported compression type (%d)"), c);
+ ds_put_format (zm->errmsgs, _("Unsupported compression type (%d)"), c);
which = n_COMPRESSION;
break;
}
which = n_COMPRESSION;
break;
}
void
zip_member_finish (struct zip_member *zm)
{
void
zip_member_finish (struct zip_member *zm)
{
+ ds_clear (zm->errmsgs);
/* Probably not useful, because we would have to read right to the end of the member
if (zm->expected_crc != zm->crc)
{
/* Probably not useful, because we would have to read right to the end of the member
if (zm->expected_crc != zm->crc)
{
+ ds_clear (zm->errmsgs);
if ( bytes > zm->bytes_unread)
bytes = zm->bytes_unread;
if ( bytes > zm->bytes_unread)
bytes = zm->bytes_unread;
uint16_t comp_type;
ds_clear (zr->errs);
uint16_t comp_type;
ds_clear (zr->errs);
+ zm->errmsgs = zr->errs;
if ( ! check_magic (zr->fr, MAGIC_SOCD, zr->errs))
return NULL;
if ( ! check_magic (zr->fr, MAGIC_SOCD, zr->errs))
return NULL;
zm->fp = fopen (zr->filename, "rb");
zm->ref_cnt = 1;
zm->fp = fopen (zr->filename, "rb");
zm->ref_cnt = 1;
if ( 0 != fseeko (zm->fp, zm->offset, SEEK_SET))
{
const char *mm = strerror (errno);
if ( 0 != fseeko (zm->fp, zm->offset, SEEK_SET))
{
const char *mm = strerror (errno);
- ds_put_format (zm->errs, _("Failed to seek to start of member `%s': %s"), zm->name, mm);
+ ds_put_format (zm->errmsgs, _("Failed to seek to start of member `%s': %s"), zm->name, mm);
if (strcmp (name, zm->name) != 0)
{
if (strcmp (name, zm->name) != 0)
{
- ds_put_format (zm->errs,
+ ds_put_format (zm->errmsgs,
_("Name mismatch in zip archive. Central directory says `%s'; local file header says `%s'"),
zm->name, name);
free (name);
_("Name mismatch in zip archive. Central directory says `%s'; local file header says `%s'"),
zm->name, name);
free (name);
size_t bytes_unread; /* Number of bytes left in the member available for reading */
int ref_cnt;
size_t bytes_unread; /* Number of bytes left in the member available for reading */
int ref_cnt;
+ struct string *errmsgs; /* A string to hold error messages.
+ This string is NOT owned by this object. */