roken/mkdtemp.c: fix incorrect indexing
Both the len and the index was decremented, which made the exit condition (template[len - i] == 'X') trigger before it should. Fixes solaris10 where mkdtemp is not available.
This commit is contained in:

committed by
Nico Williams

parent
d3b08638f9
commit
64a55c30fa
@@ -59,9 +59,8 @@ mkdtemp(char *template)
|
|||||||
pid_t val = getpid();
|
pid_t val = getpid();
|
||||||
|
|
||||||
for (i = 0; i < len && i < 7 && template[len - i] == 'X'; i++) {
|
for (i = 0; i < len && i < 7 && template[len - i] == 'X'; i++) {
|
||||||
template[len] = '0' + val % 10;
|
template[len - i] = '0' + val % 10;
|
||||||
val /= 10;
|
val /= 10;
|
||||||
len--;
|
|
||||||
if (!val)
|
if (!val)
|
||||||
val = getpid();
|
val = getpid();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user