From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-boot/mbr-gpt/
Date: Mon, 5 Dec 2022 05:36:23 +0000 (UTC) [thread overview]
Message-ID: <1670218581.19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3.robbat2@gentoo> (raw)
commit: 19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 5 05:35:34 2022 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Dec 5 05:36:21 2022 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=19b45d08
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 <AT> gentoo.org>
sys-boot/mbr-gpt/mbr-gpt-0.0.1-r1.ebuild | 5 +++++
sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
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() {
next reply other threads:[~2022-12-05 5:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 5:36 Robin H. Johnson [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-12-05 5:24 [gentoo-commits] repo/gentoo:master commit in: sys-boot/mbr-gpt/ Robin H. Johnson
2022-01-16 23:03 Mike Gilbert
2021-05-13 13:55 David Seifert
2021-04-16 10:25 David Seifert
2021-04-03 15:44 Sam James
2020-02-13 21:40 David Seifert
2019-06-16 19:17 Robin H. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1670218581.19b45d085c9fe12820eaa5d89eb9469a8d8b3bb3.robbat2@gentoo \
--to=robbat2@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox