From c40f2eef166a2e3c20abb2a0b4cdd800259b9a63 Mon Sep 17 00:00:00 2001 From: David Malone Date: Sun, 23 Feb 2003 16:49:14 +0000 Subject: [PATCH] After calling login_getclass, be sure to call login_close so that we don't leak memory. Only one of these two cases (reconfig) actually causes a leak because the other is usually followed by an exec. PR: 46845 Reviewed by: David Wang MFC after: 2 weeks --- usr.sbin/inetd/inetd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 9e66f2174ad..238e727bac3 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -833,6 +833,7 @@ main(int argc, char **argv) sep->se_service, sep->se_user); _exit(EX_OSERR); } + login_close(lc); #else if (pwd->pw_uid) { if (setlogin(sep->se_user) < 0) { @@ -971,6 +972,9 @@ config(void) struct servtab *sep, *new, **sepp; long omask; int new_nomapped; +#ifdef LOGIN_CAP + login_cap_t *lc = NULL; +#endif if (!setconfig()) { syslog(LOG_ERR, "%s: %m", CONFIG); @@ -992,13 +996,14 @@ config(void) continue; } #ifdef LOGIN_CAP - if (login_getclass(new->se_class) == NULL) { + if ((lc = login_getclass(new->se_class)) == NULL) { /* error syslogged by getclass */ syslog(LOG_ERR, "%s/%s: %s: login class error, service ignored", new->se_service, new->se_proto, new->se_class); continue; } + login_close(lc); #endif new_nomapped = new->se_nomapped; for (sep = servtab; sep; sep = sep->se_next)