aboutsummaryrefslogtreecommitdiff
path: root/fastjar/jartool.c
diff options
context:
space:
mode:
Diffstat (limited to 'fastjar/jartool.c')
-rw-r--r--fastjar/jartool.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fastjar/jartool.c b/fastjar/jartool.c
index 7cc06aaad5b..615cc401834 100644
--- a/fastjar/jartool.c
+++ b/fastjar/jartool.c
@@ -1471,9 +1471,6 @@ int extract_jar(int fd, char **files, int file_num){
}
if(method == 8 || flags & 0x0008){
- if(seekable)
- lseek(fd, eflen, SEEK_CUR);
- else
consume(&pbf, eflen);
inflate_file(&pbf, f_fd, &ze);
@@ -1508,9 +1505,6 @@ int extract_jar(int fd, char **files, int file_num){
#endif
}
- if(seekable)
- lseek(fd, eflen, SEEK_CUR);
- else
consume(&pbf, eflen);
}
@@ -1571,7 +1565,7 @@ int list_jar(int fd, char **files, int file_num){
int i, j;
time_t tdate;
struct tm *s_tm;
- char ascii_date[30];
+ char ascii_date[31];
zipentry ze;
#ifdef DEBUG
@@ -1662,6 +1656,7 @@ int list_jar(int fd, char **files, int file_num){
tdate = dos2unixtime(mdate);
s_tm = localtime(&tdate);
strftime(ascii_date, 30, "%a %b %d %H:%M:%S %Z %Y", s_tm);
+ ascii_date[30] = '\0';
}
if(filename_len < fnlen + 1){
@@ -1781,6 +1776,7 @@ int list_jar(int fd, char **files, int file_num){
tdate = dos2unixtime(mdate);
s_tm = localtime(&tdate);
strftime(ascii_date, 30, "%a %b %d %H:%M:%S %Z %Y", s_tm);
+ ascii_date[30] = '\0';
}
if(filename_len < fnlen + 1){
@@ -1854,6 +1850,14 @@ int consume(pb_file *pbf, int amt){
printf("Consuming %d bytes\n", amt);
#endif
+ if (seekable){
+ if (amt <= (int)pbf->buff_amt)
+ pb_read(pbf, buff, amt);
+ else {
+ lseek(pbf->fd, amt - pbf->buff_amt, SEEK_CUR);
+ pb_read(pbf, buff, pbf->buff_amt); /* clear pbf */
+ }
+ } else
while(tc < amt){
rdamt = pb_read(pbf, buff, ((amt - tc) < RDSZ ? (amt - tc) : RDSZ));
#ifdef DEBUG
@@ -1863,7 +1867,7 @@ int consume(pb_file *pbf, int amt){
}
#ifdef DEBUG
- printf("%d bytes consumed\n", tc);
+ printf("%d bytes consumed\n", amt);
#endif
return 0;