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:
+4
-14
@@ -142,15 +142,7 @@ getlogin(void)
|
|||||||
long
|
long
|
||||||
freediskspace(char *path)
|
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;
|
long freeBytes = 0;
|
||||||
#endif
|
|
||||||
struct InfoData *infoData; /* Remember... longword aligned */
|
struct InfoData *infoData; /* Remember... longword aligned */
|
||||||
char fileName[32];
|
char fileName[32];
|
||||||
|
|
||||||
@@ -192,11 +184,6 @@ freediskspace(char *path)
|
|||||||
infoData->id_NumBlocks - infoData->id_NumBlocksUsed;
|
infoData->id_NumBlocks - infoData->id_NumBlocksUsed;
|
||||||
freeBytes -= (freeBytes + EXTENSION) / (EXTENSION + 1);
|
freeBytes -= (freeBytes + EXTENSION) / (EXTENSION + 1);
|
||||||
freeBytes *= infoData->id_BytesPerBlock;
|
freeBytes *= infoData->id_BytesPerBlock;
|
||||||
#ifdef UNTESTED
|
|
||||||
if (freeBytes > LONG_MAX) {
|
|
||||||
freeBytes = LONG_MAX;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (freeBytes < 0)
|
if (freeBytes < 0)
|
||||||
freeBytes = 0;
|
freeBytes = 0;
|
||||||
@@ -368,8 +355,11 @@ fopenp(const char *name, const char *mode)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
lastch = *bp++ = *pp++;
|
lastch = *bp++ = *pp++;
|
||||||
}
|
}
|
||||||
if (lastch != ':' && lastch != '/' && bp != buf)
|
if (lastch != ':' && lastch != '/' && bp != buf) {
|
||||||
|
if (bp >= buf + BUFSIZ - 2)
|
||||||
|
return (NULL);
|
||||||
*bp++ = '/';
|
*bp++ = '/';
|
||||||
|
}
|
||||||
if (bp + strlen(name) > buf + BUFSIZ - 1)
|
if (bp + strlen(name) > buf + BUFSIZ - 1)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
strcpy(bp, name);
|
strcpy(bp, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user