From e8d02c50d76e278f91455bd90e1db2ae79eac035 Mon Sep 17 00:00:00 2001 From: Hyeongseok Kim Date: Mon, 10 Aug 2020 12:11:57 +0900 Subject: libsparse: Fix overflow of merged sparse chunk length Merging sparse chunk can make sparse map block bigger than 4GiB, that can't be covered by unsigned integer type. Fix this by changing unsigned int to uint64_t type. Test: sparse build Bug: 162808120 Change-Id: Id4d3f88f9d531c25c3937c99b2c81efb915605ee Signed-off-by: Hyeongseok Kim Cc: hyeongseok.kim --- libsparse/include/sparse/sparse.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'libsparse/include/sparse/sparse.h') diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h index 3d5fb0c53..2f75349a6 100644 --- a/libsparse/include/sparse/sparse.h +++ b/libsparse/include/sparse/sparse.h @@ -75,8 +75,7 @@ void sparse_file_destroy(struct sparse_file *s); * * Returns 0 on success, negative errno on error. */ -int sparse_file_add_data(struct sparse_file *s, - void *data, unsigned int len, unsigned int block); +int sparse_file_add_data(struct sparse_file* s, void* data, uint64_t len, unsigned int block); /** * sparse_file_add_fill - associate a fill chunk with a sparse file @@ -93,8 +92,8 @@ int sparse_file_add_data(struct sparse_file *s, * * Returns 0 on success, negative errno on error. */ -int sparse_file_add_fill(struct sparse_file *s, - uint32_t fill_val, unsigned int len, unsigned int block); +int sparse_file_add_fill(struct sparse_file* s, uint32_t fill_val, uint64_t len, + unsigned int block); /** * sparse_file_add_file - associate a chunk of a file with a sparse file @@ -116,9 +115,8 @@ int sparse_file_add_fill(struct sparse_file *s, * * Returns 0 on success, negative errno on error. */ -int sparse_file_add_file(struct sparse_file *s, - const char *filename, int64_t file_offset, unsigned int len, - unsigned int block); +int sparse_file_add_file(struct sparse_file* s, const char* filename, int64_t file_offset, + uint64_t len, unsigned int block); /** * sparse_file_add_file - associate a chunk of a file with a sparse file @@ -143,8 +141,8 @@ int sparse_file_add_file(struct sparse_file *s, * * Returns 0 on success, negative errno on error. */ -int sparse_file_add_fd(struct sparse_file *s, - int fd, int64_t file_offset, unsigned int len, unsigned int block); +int sparse_file_add_fd(struct sparse_file* s, int fd, int64_t file_offset, uint64_t len, + unsigned int block); /** * sparse_file_write - write a sparse file to a file -- cgit v1.2.3