projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix system breakage window during make install due to permissions
[musl]
/
src
/
temp
/
mkostemps.c
diff --git
a/src/temp/mkostemps.c
b/src/temp/mkostemps.c
index
d87d4b6
..
7f8492a
100644
(file)
--- a/
src/temp/mkostemps.c
+++ b/
src/temp/mkostemps.c
@@
-10,18
+10,19
@@
char *__randname(char *);
int __mkostemps(char *template, int len, int flags)
{
size_t l = strlen(template);
int __mkostemps(char *template, int len, int flags)
{
size_t l = strlen(template);
- if (l<6 || len>l-6 ||
strn
cmp(template+l-len-6, "XXXXXX", 6)) {
+ if (l<6 || len>l-6 ||
mem
cmp(template+l-len-6, "XXXXXX", 6)) {
errno = EINVAL;
return -1;
}
int fd, retries = 100;
errno = EINVAL;
return -1;
}
int fd, retries = 100;
-
while (retries--)
{
+
do
{
__randname(template+l-len-6);
if ((fd = open(template, flags | O_RDWR | O_CREAT | O_EXCL, 0600))>=0)
return fd;
__randname(template+l-len-6);
if ((fd = open(template, flags | O_RDWR | O_CREAT | O_EXCL, 0600))>=0)
return fd;
- if (errno != EEXIST) return -1;
- }
+ } while (--retries && errno == EEXIST);
+
+ memcpy(template+l-len-6, "XXXXXX", 6);
return -1;
}
return -1;
}