summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross2012-07-23 19:09:42 -0500
committerColin Cross2012-07-23 19:11:29 -0500
commitf1ec8ac84a8540b92a16f187bfa92b2f3c63917e (patch)
tree1e2133a96b43a76d8b9dc7f9c795001ed09c4f53 /libsparse
parentec7d9dc713322bd41b1e348c0ea3b1304a13dba9 (diff)
downloadplatform-system-core-f1ec8ac84a8540b92a16f187bfa92b2f3c63917e.tar.gz
platform-system-core-f1ec8ac84a8540b92a16f187bfa92b2f3c63917e.tar.xz
platform-system-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.c2
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)
139 DIV_ROUND_UP(backed_block_len(bb), s->block_size); 139 DIV_ROUND_UP(backed_block_len(bb), s->block_size);
140 } 140 }
141 141
142 pad = s->len - last_block * s->block_size; 142 pad = s->len - (int64_t)last_block * s->block_size;
143 assert(pad >= 0); 143 assert(pad >= 0);
144 if (pad > 0) { 144 if (pad > 0) {
145 write_skip_chunk(out, pad); 145 write_skip_chunk(out, pad);