summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2022-12-04 21:35:34 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2022-12-04 21:36:21 -0800
commit19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3 (patch)
treed0f93fee86a786a6f26ac71c54771cd4ca6985ee /sys-boot
parentsci-physics/bullet: keyword 3.21 for ~loong (diff)
downloadgentoo-19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3.tar.gz
gentoo-19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3.tar.bz2
gentoo-19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3.zip
sys-boot/mbr-gpt: add safety check
If the compiler/linker/objdump options make the mbr too large, bail out, so nobody accidently wipes out the start of their drives with a large MBR. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'sys-boot')
-rw-r--r--sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild5
-rw-r--r--sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild7
2 files changed, 11 insertions, 1 deletions
diff --git a/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild
index 3073a1e1cfed..1b062d5e5648 100644
--- a/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild
+++ b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild
@@ -44,6 +44,11 @@ src_prepare() {
src_compile() {
emake CC="$(tc-getCC)"
+ # validate the size, it MUST fit into an MBR (440 bytes!)
+ size=$(stat --printf='%s' mbr)
+ if test $size -gt 440; then
+ die "Compiled MBR is too large! Must be at most 440 bytes, was $size"
+ fi
}
src_install() {
diff --git a/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild
index df636e06b770..9359c8200a24 100644
--- a/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild
+++ b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild
@@ -27,7 +27,7 @@ QA_PRESTRIPPED="${QA_WX_LOAD}"
QA_FLAGS_IGNORED="${QA_WX_LOAD}"
# Don't strip it either; this binary reboots your host!
-RESTRICT="binchecks strip"
+RESTRICT="strip"
src_prepare() {
default
@@ -46,6 +46,11 @@ src_prepare() {
src_compile() {
emake CC="$(tc-getCC)"
+ # validate the size, it MUST fit into an MBR (440 bytes!)
+ size=$(stat --printf='%s' mbr)
+ if test $size -gt 440; then
+ die "Compiled MBR is too large! Must be at most 440 bytes, was $size"
+ fi
}
src_install() {