bugfastjar - Bugs: bug #45982, fastjar corrupts last file in...

 
 

bug #45982: fastjar corrupts last file in archive if updated

Submitted by:  None
Submitted on:  Wed 16 Sep 2015 08:08:35 PM UTC  
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 16 Sep 2015 08:08:35 PM UTC, original submission:

If you have an archive and you update it and the update includes the last file in the archive, then that file is corrupted in the resulting archive.

Test case showing problem included.

This tiny patch solves the problem for me:

diff -urN fastjar-0.98/compress.c fastjar-0.98.fixed/compress.c
--- fastjar-0.98/compress.c 2008-10-15 17:25:36.000000000 +0000
+++ fastjar-0.98.fixed/compress.c 2015-09-16 19:46:59.600910166 +0000
@@ -86,6 +86,10 @@
exit(EXIT_FAILURE);
}
}
+ else if (!next && here + len >= end_of_entries)
+ {
+ end_of_entries = here + len;
+ }
}

return write (fd, buf, len);

I suspect adding the manifests might also have a problem (but I didn't test it) and might need something like this:

diff -urN fastjar-0.98/jartool.c fastjar-0.98.fixed/jartool.c
--- fastjar-0.98/jartool.c 2015-09-16 19:48:21.000000000 +0000
+++ fastjar-0.98.fixed/jartool.c 2015-09-16 19:49:36.006209825 +0000
@@ -1274,17 +1274,24 @@
compress_file(ffd, jfd, ze, existing);
} else {
/* If we are not writing the last entry, make space for it. */
- if (existing && existing->next_entry)
+ if (existing)
{
- if (ze->usize > existing->usize)
+ if (existing->next_entry)
{
- if (shift_down (jfd, existing->next_entry->offset,
- ze->usize - existing->usize, existing->next_entry))
+ if (ze->usize > existing->usize)
{
- fprintf (stderr, "%s: %s\n", progname, strerror (errno));
- return 1;
+ if (shift_down (jfd, existing->next_entry->offset,
+ ze->usize - existing->usize, existing->next_entry))
+ {
+ fprintf (stderr, "%s: %s\n", progname, strerror (errno));
+ return 1;
+ }
}
}
+ else
+ {
+ end_of_entries += (ze->usize - existing->usize);
+ }
}

/* Write the contents of the file (uncompressed) to the zip file */

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #34904:  fastjar-update-test.tgz added by None (466B - application/x-compressed-tar)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

 

 

Follows 1 latest change.

Date Changed by Updated Field Previous Value => Replaced by
2015-09-16 None Attached File- => Added fastjar-update-test.tgz, #34904

Back to the top


Powered by Savane 3.3