Browse Source

Stratum: extract_sockaddr: Truncate overlong addresses rather than stack overflow

Thanks to Mick Ayzenberg <mick@dejavusecurity.com> for finding this!
Luke Dashjr 11 years ago
parent
commit
c80ad85482
1 changed files with 7 additions and 0 deletions
  1. 7 0
      util.c

+ 7 - 0
util.c

@@ -1002,6 +1002,13 @@ bool extract_sockaddr(struct pool *pool, char *url)
 
 	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);