Security patch from OpenBSD: fixes potential buffer overflow in a static

buffer (so more difficult to exploit but better safe than sorry). Found
by comparing FreeBSD & OpenBSD sources/logs for the auditing process.

Reviewed by:	Warner Losh
Obtained from:	OpenBSD
This commit is contained in:
Ollivier Robert 1997-02-20 22:16:39 +00:00
parent 7e05e70c2c
commit a14390ccec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22953

View File

@ -1023,7 +1023,7 @@ ns_print(sns)
struct ns_addr work;
union { union ns_net net_e; u_long long_e; } net;
u_short port;
static char mybuf[50], cport[10], chost[25];
static char mybuf[50+MAXHOSTNAMELEN], cport[10], chost[25];
char *host = "";
register char *p;
register u_char *q;
@ -1056,7 +1056,8 @@ ns_print(sns)
else
*cport = 0;
(void) sprintf(mybuf,"%lxH.%s%s", (unsigned long)ntohl(net.long_e),
(void) snprintf(mybuf, sizeof(mybuf), "%lxH.%s%s",
(unsigned long)ntohl(net.long_e),
host, cport);
return (mybuf);
}