diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2010-09-14 04:17:24 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2010-09-14 04:18:11 +0200 |
commit | a7876db304a29c330eb1ad584933176939287fc8 (patch) | |
tree | 71489af16d8ee14b080a8e1eb187c3c20e880c0d | |
parent | d3a93bfdd33107dea491ffdf5e55b34eebae475a (diff) |
Fix compressed binaries execution
* exec/exec.c (check_gzip.zipread): Add `n' to `zipread_pos' to fix infinite loop.
(check_bzip2.zipread): Likewise.
(check_gzip): Set `file_data' and `file_size' fields after calling `finish'
instead of before.
(check_bzip2): Likewise.
-rw-r--r-- | exec/exec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/exec/exec.c b/exec/exec.c index 9273a4cb..d8765003 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -1151,6 +1151,7 @@ check_gzip (struct execdata *earg) } n = MIN (maxread, map_buffer (e) + map_fsize (e) - contents); memcpy (buf, contents, n); /* XXX/fault */ + zipread_pos += n; return n; } void zipwrite (const char *buf, size_t nwrite) @@ -1210,8 +1211,6 @@ check_gzip (struct execdata *earg) /* The output is complete. Clean up the stream and store its resultant buffer and size in the execdata as the file contents. */ fclose (zipout); - e->file_data = zipdata; - e->file_size = zipdatasz; /* Clean up the old exec file stream's state. Now that we have the contents all in memory (in E->file_data), @@ -1219,6 +1218,8 @@ check_gzip (struct execdata *earg) finish (e, 0); /* Prepare the stream state to use the file contents already in memory. */ + e->file_data = zipdata; + e->file_size = zipdatasz; prepare_in_memory (e); } #endif @@ -1257,6 +1258,7 @@ check_bzip2 (struct execdata *earg) } n = MIN (maxread, map_buffer (e) + map_fsize (e) - contents); memcpy (buf, contents, n); /* XXX/fault */ + zipread_pos += n; return n; } void zipwrite (const char *buf, size_t nwrite) @@ -1305,8 +1307,6 @@ check_bzip2 (struct execdata *earg) /* The output is complete. Clean up the stream and store its resultant buffer and size in the execdata as the file contents. */ fclose (zipout); - e->file_data = zipdata; - e->file_size = zipdatasz; /* Clean up the old exec file stream's state. Now that we have the contents all in memory (in E->file_data), @@ -1314,6 +1314,8 @@ check_bzip2 (struct execdata *earg) finish (e, 0); /* Prepare the stream state to use the file contents already in memory. */ + e->file_data = zipdata; + e->file_size = zipdatasz; prepare_in_memory (e); } #endif |