Skip to content

Commit

Permalink
Don't be lazy when printing openssl version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Apr 8, 2014
1 parent dd20d3f commit afabc2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/tls.c
Expand Up @@ -64,7 +64,7 @@ static libssl_defect_t libssl_defects[] =
{
{
.low = 0x010001000, /* 1.0.1 */
.high = 0x010001060, /* 1.0.1f */
.high = 0x01000106f, /* 1.0.1f */
.id = "CVE-2014-0160",
.name = "Heartbleed",
.comment = "For more information see http://heartbleed.com"
Expand Down
17 changes: 11 additions & 6 deletions src/main/version.c
Expand Up @@ -69,13 +69,18 @@ int ssl_check_consistency(void)
char const *ssl_version_by_num(uint64_t v)
{
static char buffer[12];
char *p = buffer;

snprintf(buffer, sizeof(buffer), "%i.%i.%i%c %i",
(int) ((0xff0000000 & v) >> 28),
(int) ((0x00ff00000 & v) >> 20),
(int) ((0x0000ff000 & v) >> 12),
(char)((0x000000ff0 & v) >> 4 ? (0x60 + ((0x000000ff0 & v) >> 4)) : ' '),
(int) ((0x00000000f & v)));
p += sprintf(p, "%i.%i.%i",
(int) ((0xff0000000 & v) >> 28),
(int) ((0x00ff00000 & v) >> 20),
(int) ((0x0000ff000 & v) >> 12));

if ((0x000000ff0 & v) >> 4) {
*p++ = (char) (0x60 + ((0x000000ff0 & v) >> 4));
}

sprintf(p, " %i", (int) (0x00000000f & v));

return buffer;
}
Expand Down

0 comments on commit afabc2c

Please sign in to comment.