summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-09-24 17:36:54 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-09-24 17:36:54 +0000
commit44eccc305057561641268f38e186635eaffa766c (patch)
treec0ec3c2750ed2cf9b436c209034e26e3d2c8fffa
parent8bad5a57c21169c9d2f1898cdd5bafb4a42ffb38 (diff)
Allocate vis_user on the stack instead of using malloc(). This
way we don't have to worry about malloc() failure. Also closes a memory leak since vis_user was never free()d. Lack of malloc() checking pointed out by Peter Werner.
-rw-r--r--libexec/talkd/announce.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c
index b0556fca1a6..05be3e7256d 100644
--- a/libexec/talkd/announce.c
+++ b/libexec/talkd/announce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: announce.c,v 1.14 2002/07/07 08:54:50 jufi Exp $ */
+/* $OpenBSD: announce.c,v 1.15 2002/09/24 17:36:53 millert Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -35,7 +35,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)announce.c 5.9 (Berkeley) 2/26/91";*/
-static char rcsid[] = "$Id: announce.c,v 1.14 2002/07/07 08:54:50 jufi Exp $";
+static char rcsid[] = "$Id: announce.c,v 1.15 2002/09/24 17:36:53 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -108,7 +108,7 @@ print_mesg(tf, request, remote_machine)
char line_buf[N_LINES][N_CHARS];
int sizes[N_LINES];
char big_buf[(N_LINES + 1) * N_CHARS];
- char *bptr, *lptr, *vis_user;
+ char *bptr, *lptr, vis_user[sizeof(request->l_name) * 4];
int i, j, max_size;
i = 0;
@@ -126,7 +126,6 @@ print_mesg(tf, request, remote_machine)
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
- vis_user = (char *) malloc(strlen(request->l_name) * 4 + 1);
strvis(vis_user, request->l_name, VIS_CSTYLE);
(void)snprintf(line_buf[i], N_CHARS,
"talk: connection requested by %s@%s.",