]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Fixed potential collision in guid_generate()
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Fri, 8 Apr 2016 11:19:52 +0000 (14:19 +0300)
committerGitLab <gitlab@git.dovecot.net>
Sat, 7 May 2016 16:15:58 +0000 (19:15 +0300)
There wasn't enough padding for tv_nsec and it was also assuming 16 bit
PIDs. Because of these there was a tiny possibility of two
guid_generate() calls returning the same GUID.

This changes the GUID format a bit, but it was used only by sdbox code,
which doesn't assume anything about the GUID format.

src/lib/guid.c

index b0524dbb51fd384032c175873923c94d753479f3..91db63248dd13735f4607f8928aca090a90f6bc2 100644 (file)
@@ -29,7 +29,7 @@ const char *guid_generate(void)
                ts.tv_sec++;
                ts.tv_nsec = 0;
        }
-       return t_strdup_printf("%04x%04lx%04x%s",
+       return t_strdup_printf("%08x%08lx.%x.%s",
                               (unsigned int)ts.tv_nsec,
                               (unsigned long)ts.tv_sec,
                               pid, my_hostname);