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.
This commit is contained in:
Ingo Paschke
2026-05-12 15:19:28 +02:00
parent 157c005f02
commit ebcf31a4da
+4 -14
View File
@@ -142,15 +142,7 @@ getlogin(void)
long
freediskspace(char *path)
{
#ifdef UNTESTED
/* these changes from Patric Mueller <bhaak@gmx.net> 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);