summaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs/utilities.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-03-22 20:24:33 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-03-22 20:24:33 +0000
commit7a84eeaefb730ed882dadd3082e3d4f9c1edf250 (patch)
treefa7c5e94f9a0541e5026db02cf24056ae8b85592 /sbin/fsck_ffs/utilities.c
parent82b54f0f3f93de8d6fd760bb2514479ea752b604 (diff)
earlier asprintf diff caused malloc in signal handler. clarify the
code a bit more so that this mistake will not be done again
Diffstat (limited to 'sbin/fsck_ffs/utilities.c')
-rw-r--r--sbin/fsck_ffs/utilities.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index ae7406f1cf6..b383edc0afc 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.23 2006/03/20 20:00:05 dhill Exp $ */
+/* $OpenBSD: utilities.c,v 1.24 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: utilities.c,v 1.23 2006/03/20 20:00:05 dhill Exp $";
+static const char rcsid[] = "$OpenBSD: utilities.c,v 1.24 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -548,18 +548,19 @@ dofix(struct inodesc *idesc, char *msg)
/* NOTREACHED */
}
-int (* info_fn)(char *) = NULL;
+int (* info_fn)(char *, size_t) = NULL;
char *info_filesys = "?";
+/*ARGSUSED*/
void
-catchinfo(int n)
+catchinfo(int signo)
{
int save_errno = errno;
- char *buf = NULL;
+ char buf[1024];
struct iovec iov[4];
int fd;
- if (info_fn != NULL && info_fn(buf)) {
+ if (info_fn != NULL && info_fn(buf, sizeof buf)) {
fd = open(_PATH_TTY, O_WRONLY);
if (fd >= 0) {
iov[0].iov_base = info_filesys;
@@ -575,8 +576,6 @@ catchinfo(int n)
close(fd);
}
}
- if (buf)
- free(buf);
errno = save_errno;
}