diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2018-12-15 22:02:57 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2018-12-16 00:11:38 +0100 |
commit | 60d9f58bfdbe615f3b85140d1f5f17bf81c5ef06 (patch) | |
tree | b623c15240110de7d927ec3f3b54401c2e619fa1 | |
parent | f746d6cf5256c5f47e239bf6b1f5b92389c05a2a (diff) | |
download | genimage-60d9f58bfdbe615f3b85140d1f5f17bf81c5ef06.tar.gz genimage-60d9f58bfdbe615f3b85140d1f5f17bf81c5ef06.tar.xz |
hdimage: make sure partitions are large enough for the content
Add a check to validate this.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | image-hd.c | 4 | ||||
-rwxr-xr-x | test/basic-images.test | 5 | ||||
-rw-r--r-- | test/hdimage2.config | 10 |
4 files changed, 20 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index e1668ab..8455bfc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,6 +60,7 @@ EXTRA_DIST += \ test/flash.config \ test/flash.md5 \ test/hdimage.config \ + test/hdimage2.config \ test/hdimage.fdisk \ test/hdimage.fdisk-2 \ test/iso.config \ @@ -271,6 +271,10 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) part->size = roundup(child->size, hd->align); else part->size = child->size; + } else if (child->size > part->size) { + image_error(image, "part %s size (%lld) too small for %s (%lld)\n", + part->name, part->size, child->file, child->size); + return -EINVAL; } } if (!part->size) { diff --git a/test/basic-images.test b/test/basic-images.test index c25a143..4439fc2 100755 --- a/test/basic-images.test +++ b/test/basic-images.test @@ -209,6 +209,11 @@ test_expect_success fdisk,sfdisk "hdimage" " test_cmp '${testdir}/hdimage.fdisk-2' hdimage.fdisk-2 " +test_expect_success "hdimage2" " + setup_test_images && + test_must_fail run_genimage hdimage2.config test.hdimage +" + exec_test_set_prereq genisoimage test_expect_success genisoimage "iso" " run_genimage iso.config test.iso && diff --git a/test/hdimage2.config b/test/hdimage2.config new file mode 100644 index 0000000..79f8a2e --- /dev/null +++ b/test/hdimage2.config @@ -0,0 +1,10 @@ +image test.hdimage { + hdimage { + align = 1M + disk-signature = 0x12345678 + } + partition part1 { + image = "part2.img" + size = 5k + partition-type = 0x83 + } |