mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix mkostemps and mkdtemp not restoring X's on error.
This commit is contained in:
parent
447f0596ad
commit
13e8e092a6
2 changed files with 9 additions and 4 deletions
|
@ -59,5 +59,7 @@ extern "C" char* mkdtemp(char* templ)
|
|||
return templ;
|
||||
} while ( errno == EEXIST );
|
||||
|
||||
memcpy(templ + xpos, "XXXXXX", 6);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -54,13 +54,16 @@ extern "C" int mkostemps(char* templ, int suffixlen, int flags)
|
|||
return errno = EINVAL, -1;
|
||||
|
||||
flags &= ~O_ACCMODE;
|
||||
int fd;
|
||||
do
|
||||
{
|
||||
for ( size_t i = 0; i < 6; i++ )
|
||||
templ[xpos + i] = random_character();
|
||||
} while ( (fd = open(templ, flags | O_RDWR | O_EXCL | O_CREAT, 0600)) < 0 &&
|
||||
(errno == EEXIST) );
|
||||
|
||||
int fd = open(templ, flags | O_RDWR | O_EXCL | O_CREAT, 0600);
|
||||
if ( 0 <= fd )
|
||||
return fd;
|
||||
} while ( errno == EEXIST );
|
||||
|
||||
memcpy(templ + xpos, "XXXXXX", 6);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue