diff options
author | Colin Cross <ccross@android.com> | 2012-07-23 17:09:42 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2012-07-23 17:11:29 -0700 |
commit | f1ec8ac84a8540b92a16f187bfa92b2f3c63917e (patch) | |
tree | 1e2133a96b43a76d8b9dc7f9c795001ed09c4f53 /libsparse | |
parent | ec7d9dc713322bd41b1e348c0ea3b1304a13dba9 (diff) | |
download | core-f1ec8ac84a8540b92a16f187bfa92b2f3c63917e.tar.gz core-f1ec8ac84a8540b92a16f187bfa92b2f3c63917e.tar.bz2 core-f1ec8ac84a8540b92a16f187bfa92b2f3c63917e.zip |
libsparse: fix 32 bit overflow when calculating last chunk
last_block * s->block_size can overflow when writing large filesystems,
cast to 64 bits before multiplying.
Change-Id: I3e54097852ce7d0fd271eab53d65e666284898e4
Diffstat (limited to 'libsparse')
-rw-r--r-- | libsparse/sparse.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libsparse/sparse.c b/libsparse/sparse.c index 189b4c03e..741e8c6fc 100644 --- a/libsparse/sparse.c +++ b/libsparse/sparse.c @@ -139,7 +139,7 @@ static int write_all_blocks(struct sparse_file *s, struct output_file *out) DIV_ROUND_UP(backed_block_len(bb), s->block_size); } - pad = s->len - last_block * s->block_size; + pad = s->len - (int64_t)last_block * s->block_size; assert(pad >= 0); if (pad > 0) { write_skip_chunk(out, pad); |