Fix issues when handling Jpegs where packJPG borks.

This commit is contained in:
Moinak Ghosh 2013-11-15 23:02:09 +05:30
parent 11584cab52
commit c09a2b7b81
2 changed files with 5 additions and 6 deletions

View file

@ -195,8 +195,8 @@ packjpg_filter(struct filter_info *fi, void *filter_private)
*/ */
if ((mapbuf[0] != 'J' && mapbuf[1] != 'S') || if ((mapbuf[0] != 'J' && mapbuf[1] != 'S') ||
(pjdat->in_buff[0] == 0xFF && pjdat->in_buff[1] == 0xD8)) { (pjdat->in_buff[0] == 0xFF && pjdat->in_buff[1] == 0xD8)) {
return (write_archive_data(fi->target_arc, mapbuf, in_size, return (write_archive_data(fi->target_arc, pjdat->in_buff,
fi->block_size)); in_size, fi->block_size));
} }
} }
if (pjdat->bufflen < len) { if (pjdat->bufflen < len) {
@ -218,8 +218,10 @@ packjpg_filter(struct filter_info *fi, void *filter_private)
out = pjdat->buff; out = pjdat->buff;
if ((len = packjpg_filter_process(mapbuf, len, &out)) == 0) { if ((len = packjpg_filter_process(mapbuf, len, &out)) == 0) {
munmap(mapbuf, len1);
return (FILTER_RETURN_SKIP); return (FILTER_RETURN_SKIP);
} }
munmap(mapbuf, len1);
in_size = LE64(len); in_size = LE64(len);
rv = archive_write_data(fi->target_arc, &in_size, 8); rv = archive_write_data(fi->target_arc, &in_size, 8);

View file

@ -842,7 +842,6 @@ process_by_filter(int fd, int typ, struct archive *target_arc,
fi.compressing = cmp; fi.compressing = cmp;
fi.block_size = AW_BLOCK_SIZE; fi.block_size = AW_BLOCK_SIZE;
wrtn = (*(typetab[(typ >> 3)].filter_func))(&fi, typetab[(typ >> 3)].filter_private); wrtn = (*(typetab[(typ >> 3)].filter_func))(&fi, typetab[(typ >> 3)].filter_private);
close(fd);
if (wrtn == FILTER_RETURN_ERROR) { if (wrtn == FILTER_RETURN_ERROR) {
log_msg(LOG_ERR, 0, "Error invoking filter module: %s", log_msg(LOG_ERR, 0, "Error invoking filter module: %s",
typetab[(typ >> 3)].filter_name); typetab[(typ >> 3)].filter_name);
@ -881,9 +880,7 @@ copy_file_data(pc_ctx_t *pctx, struct archive *arc, struct archive_entry *entry,
rv = process_by_filter(fd, typ, arc, NULL, entry, 1); rv = process_by_filter(fd, typ, arc, NULL, entry, 1);
if (rv == FILTER_RETURN_ERROR) if (rv == FILTER_RETURN_ERROR)
return (-1); return (-1);
else if (rv == FILTER_RETURN_SKIP) else if (rv != FILTER_RETURN_SKIP)
lseek(fd, 0, SEEK_SET);
else
return (ARCHIVE_OK); return (ARCHIVE_OK);
} }
} }