summaryrefslogtreecommitdiff
path: root/sbin/init
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-30 18:09:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-30 18:09:45 +0000
commitd58abe9a9bc45dea2024d7dbc4546355dbe4843b (patch)
treef2ecbbc6b50fc56e599be1d739561c2c87004249 /sbin/init
parent03f2ddd943bae26f6a14aaca545c0471700a8512 (diff)
snprintf; millert ok
Diffstat (limited to 'sbin/init')
-rw-r--r--sbin/init/init.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index b5f332f23ec..c76873260ed 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.30 2002/12/11 21:58:37 millert Exp $ */
+/* $OpenBSD: init.c,v 1.31 2003/03/30 18:09:44 deraadt Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.30 2002/12/11 21:58:37 millert Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.31 2003/03/30 18:09:44 deraadt Exp $";
#endif
#endif /* not lint */
@@ -862,6 +862,7 @@ session_t *
new_session(session_t *sprev, int session_index, struct ttyent *typ)
{
session_t *sp;
+ size_t len;
if ((typ->ty_status & TTY_ON) == 0 ||
typ->ty_name == 0 ||
@@ -874,8 +875,9 @@ new_session(session_t *sprev, int session_index, struct ttyent *typ)
sp->se_flags = SE_PRESENT;
sp->se_index = session_index;
- sp->se_device = malloc(sizeof(_PATH_DEV) + strlen(typ->ty_name));
- (void) sprintf(sp->se_device, "%s%s", _PATH_DEV, typ->ty_name);
+ len = sizeof(_PATH_DEV) + strlen(typ->ty_name);
+ sp->se_device = malloc(len);
+ (void) snprintf(sp->se_device, len, "%s%s", _PATH_DEV, typ->ty_name);
if (setupargv(sp, typ) == 0) {
free_session(sp);
@@ -900,13 +902,15 @@ new_session(session_t *sprev, int session_index, struct ttyent *typ)
int
setupargv(session_t *sp, struct ttyent *typ)
{
+ size_t len;
if (sp->se_getty) {
free(sp->se_getty);
free(sp->se_getty_argv);
}
- sp->se_getty = malloc(strlen(typ->ty_getty) + strlen(typ->ty_name) + 2);
- (void) sprintf(sp->se_getty, "%s %s", typ->ty_getty, typ->ty_name);
+ len = strlen(typ->ty_getty) + strlen(typ->ty_name) + 2;
+ sp->se_getty = malloc(len);
+ (void) snprintf(sp->se_getty, len, "%s %s", typ->ty_getty, typ->ty_name);
sp->se_getty_argv = construct_argv(sp->se_getty);
if (sp->se_getty_argv == 0) {
warning("can't parse getty for port %s", sp->se_device);