fix(gawk): add typed read_func prototype patch and validate with dry-run AND

fix(import-payload): switch to procfs /proc/partitions major/minor enumeration with magic-verified payload import
This commit is contained in:
vxtls 2026-03-01 23:04:16 -05:00
parent 17e88a89a8
commit 45ba6a367d
3 changed files with 62 additions and 6 deletions

View file

@ -0,0 +1,53 @@
SPDX-License-Identifier: GPL-3.0-or-later
Fix read_func prototype to use a modern typed function pointer.
--- gawk-4.2.1/gawkapi.h
+++ gawk-4.2.1/gawkapi.h
@@ -190,7 +190,7 @@
* No argument prototype on read_func to allow for older systems
* whose headers are not up to date.
*/
- ssize_t (*read_func)();
+ ssize_t (*read_func)(int, void *, size_t);
/*
* The close_func is called to allow the parser to free private data.
--- gawk-4.2.1/io.c
+++ gawk-4.2.1/io.c
@@ -310,7 +310,7 @@
static NODE *in_PROCINFO(const char *pidx1, const char *pidx2, NODE **full_idx);
static long get_read_timeout(IOBUF *iop);
-static ssize_t read_with_timeout(int fd, char *buf, size_t size);
+static ssize_t read_with_timeout(int fd, void *buf, size_t size);
static bool read_can_timeout = false;
static long read_timeout;
@@ -3340,7 +3340,7 @@
iop->public.fd = fd;
iop->public.name = name;
- iop->public.read_func = ( ssize_t(*)() ) read;
+ iop->public.read_func = (ssize_t (*)(int, void *, size_t)) read;
iop->valid = false;
iop->errcode = errno_val;
@@ -4318,7 +4318,7 @@
tmout = read_default_timeout; /* initialized from env. variable in init_io() */
/* overwrite read routine only if an extension has not done so */
- if ((iop->public.read_func == ( ssize_t(*)() ) read) && tmout > 0)
+ if ((iop->public.read_func == (ssize_t (*)(int, void *, size_t)) read) && tmout > 0)
iop->public.read_func = read_with_timeout;
return tmout;
@@ -4330,7 +4330,7 @@
*/
static ssize_t
-read_with_timeout(int fd, char *buf, size_t size)
+read_with_timeout(int fd, void *buf, size_t size)
{
#if ! defined(VMS)
fd_set readfds;

View file

@ -8,8 +8,11 @@ set -ex
if [ "${PAYLOAD_REQUIRED}" = True ]; then
mkdir -p /external/distfiles
mkdir -p /proc
mount -t proc proc /proc >/dev/null 2>&1 || :
# Reliable enumeration in Fiwix: mount procfs and read /proc/partitions.
if [ ! -r /proc/partitions ]; then
mount -t proc proc /proc
fi
if [ ! -r /proc/partitions ]; then
echo "payload-import failed: /proc/partitions is unavailable." >&2
exit 1
@ -22,13 +25,13 @@ if [ "${PAYLOAD_REQUIRED}" = True ]; then
continue
;;
*[0-9])
# Skip partitions (sda1, vdb2, ...); payload is attached as a whole disk.
# Skip partitions (hda1, sdb2, ...); payload is a whole disk.
continue
;;
esac
dev_path="/dev/${name}"
mknod -m 600 "${dev_path}" b "${major}" "${minor}" >/dev/null 2>&1 || :
[ -b "${dev_path}" ] || mknod -m 600 "${dev_path}" b "${major}" "${minor}"
if payload-import --probe "${dev_path}"; then
payload-import --device "${dev_path}" /external/distfiles
@ -38,7 +41,7 @@ if [ "${PAYLOAD_REQUIRED}" = True ]; then
done < /proc/partitions
if [ "${found_payload}" != 1 ]; then
echo "payload-import failed: no payload image found on probed block devices." >&2
echo "payload-import failed: no payload image found in /proc/partitions." >&2
exit 1
fi
fi

View file

@ -227,10 +227,10 @@ static int extract_payload(const char *device, const char *dest_dir)
static int import_from_first_payload(const char *dest_dir)
{
const char *prefixes[] = {"/dev/sd", "/dev/vd", "/dev/hd"};
const char *prefixes[] = {"/dev/sd", "/dev/hd", "/dev/vd", "/dev/xvd"};
int p;
for (p = 0; p < 3; ++p) {
for (p = 0; p < 4; ++p) {
char letter;
for (letter = 'b'; letter <= 'z'; ++letter) {
char device[16];