From 7c3f709388d1fcecad658d4166a4b16845fc4451 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 24 Jan 2008 12:00:02 +0200 Subject: ubi-utils: check image file size in ubinize Signed-off-by: Artem Bityutskiy --- ubi-utils/src/ubinize.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ubi-utils/src/ubinize.c') diff --git a/ubi-utils/src/ubinize.c b/ubi-utils/src/ubinize.c index df82e0b..e36c3ba 100644 --- a/ubi-utils/src/ubinize.c +++ b/ubi-utils/src/ubinize.c @@ -570,6 +570,16 @@ int main(int argc, char * const argv[]) goto out_dict; } + /* + * Make sure the image size is not larger then the volume size. + */ + if (st.st_size > vi.bytes) { + errmsg("error in section \"%s\": size of the image file \"%s\" " + "is %lld, which is larger then the volume size %lld", + sname, img, (long long)st.st_size, vi.bytes); + goto out_dict; + } + f = fopen(img, "r"); if (!f) { errmsg("cannot open \"%s\"", img); -- cgit v1.2.3