mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- tmpnam() wrote more than L_tmpnam bytes to the name buffer. Also, the
TMP_MAX value was off by one. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15029 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
- Following detection of a stack overflow, the startup code eventually
|
||||
called _exit(). It should have called exit() instead.
|
||||
|
||||
- tmpnam() wrote more than L_tmpnam bytes to the name buffer. Also, the
|
||||
TMP_MAX value was off by one.
|
||||
|
||||
|
||||
c.lib 1.195 (3.9.2005)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio.h,v 1.16 2005-06-18 07:23:17 obarthel Exp $
|
||||
* $Id: stdio.h,v 1.17 2005-09-04 11:28:00 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -154,7 +154,7 @@ typedef struct
|
||||
#define L_tmpnam 10
|
||||
|
||||
/* Maximum number of unique file names tmpnam() can generate */
|
||||
#define TMP_MAX 0x3ffff
|
||||
#define TMP_MAX 0x40000
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_tmpnam.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $
|
||||
* $Id: stdio_tmpnam.c,v 1.5 2005-09-04 11:27:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -45,9 +45,10 @@ char *
|
||||
tmpnam(char *buf)
|
||||
{
|
||||
static char local_buffer[L_tmpnam];
|
||||
static unsigned short counter;
|
||||
static unsigned long counter;
|
||||
|
||||
APTR old_window_pointer;
|
||||
unsigned short c;
|
||||
unsigned long c;
|
||||
char * result = NULL; /* ZZZ compiler claims that this assignment is unnecessary. */
|
||||
BPTR lock;
|
||||
int i;
|
||||
@ -66,20 +67,23 @@ tmpnam(char *buf)
|
||||
if(__check_abort_enabled)
|
||||
__check_abort();
|
||||
|
||||
c = (counter++);
|
||||
c = counter;
|
||||
|
||||
counter = (counter + 1) % TMP_MAX;
|
||||
|
||||
/* Build another temporary file name, which begins with the
|
||||
* letters 'tmp' followed by an octal number.
|
||||
*/
|
||||
letters 'tmp' followed by an octal number. */
|
||||
strcpy(buf,"tmp");
|
||||
|
||||
for(i = 0 ; i < 10 ; i++)
|
||||
/* There's room for L_tmpnam - 4 digits, which for
|
||||
L_tmpnam == 10 leaves room for 6 * 3 bits. */
|
||||
for(i = 3 ; i < L_tmpnam-1 ; i++)
|
||||
{
|
||||
buf[3 + 10 - (i+1)] = '0' + (c % 8);
|
||||
buf[i] = '0' + (c % 8);
|
||||
c = (c / 8);
|
||||
}
|
||||
|
||||
buf[3 + 10] = '\0';
|
||||
buf[i] = '\0';
|
||||
|
||||
D(("checking if '%s' exists",buf));
|
||||
|
||||
@ -97,8 +101,7 @@ tmpnam(char *buf)
|
||||
if(lock == ZERO)
|
||||
{
|
||||
/* If the object does not exist yet then we
|
||||
* are finished.
|
||||
*/
|
||||
are finished. */
|
||||
if(IoErr() == ERROR_OBJECT_NOT_FOUND)
|
||||
result = buf;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user