From 91d29ea9722f83ee8ae16c157f88f65cb1182657 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 5 Jun 2014 17:05:12 +0000 Subject: [PATCH] Stratum: extract_sockaddr: Truncate overlong addresses rather than stack overflow Thanks to Mick Ayzenberg for finding this! --- util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util.c b/util.c index 1a3901bd..da9d25a2 100644 --- a/util.c +++ b/util.c @@ -1218,6 +1218,13 @@ bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port) if (url_len < 1) return false; + + if (url_len >= sizeof(url_address)) + { + applog(LOG_WARNING, "%s: Truncating overflowed address '%.*s'", + __func__, url_len, url_begin); + url_len = sizeof(url_address) - 1; + } sprintf(url_address, "%.*s", url_len, url_begin);