Author: rmilecki
Date: 2015-04-21 13:21:34 +0200 (Tue, 21 Apr 2015)
New Revision: 45547

Modified:
   trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
Log:
bcm53xx: sysupgrade: check if new kernel fits partition size

Signed-off-by: Rafa?\197?\130 Mi?\197?\130ecki <[email protected]>

Modified: trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh
===================================================================
--- trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh       
2015-04-21 11:04:38 UTC (rev 45546)
+++ trunk/target/linux/bcm53xx/base-files/lib/upgrade/platform.sh       
2015-04-21 11:21:34 UTC (rev 45547)
@@ -152,12 +152,17 @@
                echo "Unable to find \"linux\" partition size"
                exit 1
        }
-       linux_length=$((0x$linux_length + 28))
+       linux_length=$((0x$linux_length))
+       local kernel_length=$(wc -c $dir/kernel | cut -d ' ' -f 1)
+       [ $kernel_length -gt $linux_length ] && {
+               echo "New kernel doesn't fit \"linux\" partition."
+               return
+       }
        rm -f /tmp/null.bin
        rm -f /tmp/kernel.trx
        touch /tmp/null.bin
        otrx create /tmp/kernel.trx \
-               -f $dir/kernel -b $linux_length \
+               -f $dir/kernel -b $(($linux_length + 28)) \
                -f /tmp/null.bin
 
        # Prepare UBI image (drop unwanted extra blocks)
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to