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:
roberto 1997-02-20 22:16:39 +00:00
parent 1affb81d5a
commit ed1608278d

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);
}