inetd: use snprintf() in inetd_setproctitle()

inetd_setproctitle() formats se_service (the service name taken verbatim
from inetd.conf) and the peer address into an 80-byte buffer with
sprintf(). A long service name can overflow it. Bound both calls with
snprintf().

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60879
This commit is contained in:
Osvaldo Janeri Filho authored and Mark Johnston committed 2026-10-20 22:04:31 +00:00
1 parent 8dfa23d81f
commit 9ab2bf0f42
1 file changed
+2 -2
+2 -2
View File
@@ -2094,9 +2094,9 @@ inetd_setproctitle(const char *a, int s)
if (getpeername(s, (struct sockaddr *)&ss, &size) == 0) {
getnameinfo((struct sockaddr *)&ss, size, pbuf, sizeof(pbuf),
NULL, 0, NI_NUMERICHOST);
(void) sprintf(buf, "%s [%s]", a, pbuf);
(void) snprintf(buf, sizeof(buf), "%s [%s]", a, pbuf);
} else
(void) sprintf(buf, "%s", a);
(void) snprintf(buf, sizeof(buf), "%s", a);
setproctitle("%s", buf);
}