From ebcf31a4dae5575d87014f7d81b9274a49142ccf Mon Sep 17 00:00:00 2001 From: Ingo Paschke Date: Tue, 12 May 2026 15:19:28 +0200 Subject: [PATCH] Amiga: drop UNTESTED AROS path; tighten fopenp separator write The UNTESTED #ifdef in freediskspace was never gated by any hints file, so the unsigned-long-long path could only be enabled by a stray manual #define -- in which case the return type is still long and silently truncates. Remove the branches. In fopenp the separator '/' write was unchecked: when the path segment exactly filled the buffer to BUFSIZ-2 it would land at buf[BUFSIZ-1] and the follow-on NUL would write past the end. Guard the write. --- sys/amiga/amidos.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/sys/amiga/amidos.c b/sys/amiga/amidos.c index e7b22259a..097e57905 100644 --- a/sys/amiga/amidos.c +++ b/sys/amiga/amidos.c @@ -142,15 +142,7 @@ getlogin(void) long freediskspace(char *path) { -#ifdef UNTESTED - /* these changes from Patric Mueller for AROS to - * handle larger disks. Also needs limits.h and aros/oldprograms.h - * for AROS. (keni) - */ - unsigned long long freeBytes = 0; -#else long freeBytes = 0; -#endif struct InfoData *infoData; /* Remember... longword aligned */ char fileName[32]; @@ -192,11 +184,6 @@ freediskspace(char *path) infoData->id_NumBlocks - infoData->id_NumBlocksUsed; freeBytes -= (freeBytes + EXTENSION) / (EXTENSION + 1); freeBytes *= infoData->id_BytesPerBlock; -#ifdef UNTESTED - if (freeBytes > LONG_MAX) { - freeBytes = LONG_MAX; - } -#endif } if (freeBytes < 0) freeBytes = 0; @@ -368,8 +355,11 @@ fopenp(const char *name, const char *mode) return (NULL); lastch = *bp++ = *pp++; } - if (lastch != ':' && lastch != '/' && bp != buf) + if (lastch != ':' && lastch != '/' && bp != buf) { + if (bp >= buf + BUFSIZ - 2) + return (NULL); *bp++ = '/'; + } if (bp + strlen(name) > buf + BUFSIZ - 1) return (NULL); strcpy(bp, name);