NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/58663: gpt(1) biosboot.c doesn't compile on modern Linux
>Number: 58663
>Category: toolchain
>Synopsis: gpt(1) biosboot.c doesn't compile on modern Linux
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 04 04:15:01 +0000 2024
>Originator: Lloyd Parkes
>Release: 10.99.12
>Organization:
Must Have Coffee
>Environment:
Linux riftsweeper.must-have-coffee.gen.nz 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64 GNU/Linux
>Description:
The function cmd_biosboot() has a variable called start of type daddr_t. It sets this variable by calling gpt_human_get(gpt, &start).
The problem is that gpt_human_get() expects a pointer to an off_t, not a pointer to a daddr_t and on Linux these two types are different sizes. This will result in memory corruption on Linux as gpt_human_get() will modify memory that cmd_biosboot() doesn't expect it to.
An easy fix is to change the type of variable start to off_t. The later uses of start will work out fine because C implicit type conversion handles things for us.
>How-To-Repeat:
Build on amd64 Arch Linux which is new enough to have GCC 14.
>Fix:
Apply the following patch.
diff -r 3a2c38eb3772 sbin/gpt/biosboot.c
--- a/sbin/gpt/biosboot.c Tue Sep 03 19:51:02 2024 +0000
+++ b/sbin/gpt/biosboot.c Wed Sep 04 15:08:01 2024 +1200
@@ -267,7 +267,7 @@
#endif
int ch;
gpt_t ngpt = gpt;
- daddr_t start = 0;
+ off_t start = 0; /* off_t because of gpt_human_get() */
uint64_t size = 0;
int active = 0;
unsigned int entry = 0;
Home |
Main Index |
Thread Index |
Old Index