Skip to content

Commit

Permalink
Don't rely on libcrypto returning static buffers
Browse files Browse the repository at this point in the history
ike-scan is one of very few applications relying on being able to pass
NULL as last argument to the one-step hashing functions. BoringSSL
has removed this functionality in 2017 [1] and LibreSSL 4.0 will do
the same. Applications can pass in a correctly-sized buffer on the
stack.

[1]: https://boringssl-review.googlesource.com/14528
  • Loading branch information
botovq committed May 30, 2024
1 parent d5737c9 commit a22a8b6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ike-scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ add_host(const char *name, unsigned timeout, unsigned *num_hosts,
memset(he->icookie, '\0', sizeof(he->icookie));
memcpy(he->icookie, cookie_data, cookie_data_len);
} else {
unsigned char md[MD5_DIGEST_LENGTH];
/*
* We cast the timeval elements to unsigned long because different vendors
* use different types for them (int, long, unsigned int and unsigned long).
Expand All @@ -1337,7 +1338,7 @@ add_host(const char *name, unsigned timeout, unsigned *num_hosts,
*/
snprintf(str, sizeof(str), "%lu %lu %u %s", (unsigned long) now.tv_sec,
(unsigned long) now.tv_usec, *num_hosts, inet_ntoa(he->addr));
memcpy(he->icookie, MD5((unsigned char *)str, strlen(str), NULL),
memcpy(he->icookie, MD5((unsigned char *)str, strlen(str), md),
sizeof(he->icookie));
}
}
Expand Down

0 comments on commit a22a8b6

Please sign in to comment.