Skip to content

Commit

Permalink
lib: Fixed potential collision in guid_generate()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrannanj authored and GitLab committed May 7, 2016
1 parent c275cef commit 5b02d21
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/guid.c
Expand Up @@ -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);
Expand Down

0 comments on commit 5b02d21

Please sign in to comment.