From 64a55c30fa7c485a57691f6a99b0aec0ab2d67ad Mon Sep 17 00:00:00 2001 From: Robert Manner Date: Mon, 28 Nov 2022 16:44:16 +0100 Subject: [PATCH] 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. --- lib/roken/mkdtemp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/roken/mkdtemp.c b/lib/roken/mkdtemp.c index b106add32..c9f7463e9 100644 --- a/lib/roken/mkdtemp.c +++ b/lib/roken/mkdtemp.c @@ -59,9 +59,8 @@ mkdtemp(char *template) pid_t val = getpid(); 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; - len--; if (!val) val = getpid(); }