aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2016-10-28 13:58:25 +1030
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-11-02 18:42:15 +1100
commit4382d472a517d6a39f919b139eed3c86c6db9009 (patch)
tree2b77a11ea5790f5bba661b54529df264230a6bf7 /external
parent30f86e5b6ad45fffdd83dc0322d0128fe0db64c3 (diff)
downloadskiboot-4382d472a517d6a39f919b139eed3c86c6db9009.zip
skiboot-4382d472a517d6a39f919b139eed3c86c6db9009.tar.gz
skiboot-4382d472a517d6a39f919b139eed3c86c6db9009.tar.bz2
pflash: Fail when file is larger than partition
Currently we warn the user and truncate the file by default. Instead abort as this is rarely the desired behaviour. You can still shoot yourself in the foot by passing --force. Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/pflash/pflash.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 89bd2fe..c93bbd4 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -839,14 +839,20 @@ int main(int argc, char *argv[])
if (!write_size)
write_size = pmaxsz;
- /* Crop write size to partition size */
- if (write_size > pmaxsz) {
+ /* Crop write size to partition size if --force was passed */
+ if (write_size > pmaxsz && !must_confirm) {
printf("WARNING: Size (%d bytes) larger than partition"
" (%d bytes), cropping to fit\n",
write_size, pmaxsz);
write_size = pmaxsz;
+ } else if (write_size > pmaxsz) {
+ printf("ERROR: Size (%d bytes) larger than partition"
+ " (%d bytes). Use --force to force\n",
+ write_size, pmaxsz);
+ exit(1);
}
+
/* If erasing, check partition alignment */
if (erase && ((pstart | pmaxsz) & 0xfff)) {
fprintf(stderr,"Partition not aligned properly\n");