Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/atheos/atheos.c view on Meta::CPAN
ush size = 0;
ulg full_size = 0;
uch flags = 0;
uch *attrbuff = NULL;
int retval;
if( extra_field == NULL ) {
return;
}
/* Collect the data from the extra field buffer. */
id = makeword(ptr); ptr += 2; /* we don't use this... */
size = makeword(ptr); ptr += 2;
full_size = makelong(ptr); ptr += 4;
flags = *ptr; ptr++;
/* Do a little sanity checking. */
if (flags & EB_BE_FL_BADBITS) {
/* corrupted or unsupported */
Info(slide, 0x201, ((char *)slide,
"Unsupported flags set for this AtheOS extra field, skipping.\n"));
return;
}
if (size <= EB_BEOS_HLEN) {
/* corrupted, unsupported, or truncated */
Info(slide, 0x201, ((char *)slide,
"AtheOS extra field is %d bytes, should be at least %d.\n", size,
EB_BEOS_HLEN));
return;
}
if (full_size < (size - EB_BEOS_HLEN)) {
Info(slide, 0x201, ((char *)slide,
"Skipping attributes: AtheOS extra field is %d bytes, "
"data size is %ld.\n", size - EB_BEOS_HLEN, full_size));
return;
}
/* Find the AtheOS file attribute data. */
if (flags & EB_BE_FL_UNCMPR) {
/* Uncompressed data */
attrbuff = ptr;
} else {
/* Compressed data */
attrbuff = (uch *)malloc( full_size );
if (attrbuff == NULL) {
/* No memory to uncompress attributes */
Info(slide, 0x201, ((char *)slide,
"Can't allocate memory to uncompress file attributes.\n"));
return;
}
retval = memextract(__G__ attrbuff, full_size,
ptr, size - EB_BEOS_HLEN);
if( retval != PK_OK ) {
/* error uncompressing attributes */
Info(slide, 0x201, ((char *)slide,
"Error uncompressing file attributes.\n"));
/* Some errors here might not be so bad; we should expect */
/* some truncated data, for example. If the data was */
/* corrupt, we should _not_ attempt to restore the attrs */
/* for this file... there's no way to detect what attrs */
/* are good and which are bad. */
free (attrbuff);
return;
}
}
/* Now attempt to set the file attributes on the extracted file. */
retval = set_file_attrs(path, attrbuff, (off_t)full_size);
if (retval != EOK) {
Info(slide, 0x201, ((char *)slide,
"Error writing file attributes.\n"));
}
/* Clean up, if necessary */
if (attrbuff != ptr) {
free(attrbuff);
}
return;
}
( run in 1.074 second using v1.01-cache-2.11-cpan-b16cb0d3907 )