summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-03-10 03:45:25 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-03-10 03:45:25 +0000
commitfbe41912605319d09296becebbc7ce40638fb707 (patch)
treed7ea90b232220ab798fed79cf6d510ba3389ad8c /libexec
parent2b5761b9fb49bfcdacf340fc76ac575516a5011b (diff)
close file on error paths. from Patrick Latifi
Diffstat (limited to 'libexec')
-rw-r--r--libexec/talkd/announce.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c
index 52de9a1c353..afb8124a6ee 100644
--- a/libexec/talkd/announce.c
+++ b/libexec/talkd/announce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: announce.c,v 1.18 2003/06/11 14:24:46 deraadt Exp $ */
+/* $OpenBSD: announce.c,v 1.19 2004/03/10 03:45:24 tedu Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -31,7 +31,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)announce.c 5.9 (Berkeley) 2/26/91";*/
-static char rcsid[] = "$Id: announce.c,v 1.18 2003/06/11 14:24:46 deraadt Exp $";
+static char rcsid[] = "$Id: announce.c,v 1.19 2004/03/10 03:45:24 tedu Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -70,10 +70,14 @@ announce(CTL_MSG *request, char *remote_machine)
return (FAILED);
if ((tf = fopen(full_tty, "w")) == NULL)
return (PERMISSION_DENIED);
- if (fstat(fileno(tf), &stbuf) < 0)
+ if (fstat(fileno(tf), &stbuf) < 0) {
+ fclose(tf);
return (PERMISSION_DENIED);
- if ((stbuf.st_mode&S_IWGRP) == 0)
+ }
+ if ((stbuf.st_mode & S_IWGRP) == 0) {
+ fclose(tf);
return (PERMISSION_DENIED);
+ }
print_mesg(tf, request, remote_machine);
fclose(tf);
return (SUCCESS);