summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/fsck_ffs/fsck.h4
-rw-r--r--sbin/fsck_ffs/pass1.c8
-rw-r--r--sbin/fsck_ffs/pass1b.c8
-rw-r--r--sbin/fsck_ffs/pass2.c12
-rw-r--r--sbin/fsck_ffs/pass3.c8
-rw-r--r--sbin/fsck_ffs/pass4.c8
-rw-r--r--sbin/fsck_ffs/pass5.c8
-rw-r--r--sbin/fsck_ffs/utilities.c15
8 files changed, 35 insertions, 36 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 7ca2bf34f67..cbcded0882e 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsck.h,v 1.15 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: fsck.h,v 1.16 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */
/*
@@ -216,5 +216,5 @@ struct inoinfo *getinoinfo(ino_t);
void getblk(struct bufarea *, daddr_t, long);
ino_t allocino(ino_t, int);
-int (*info_fn)(char *);
+int (*info_fn)(char *, size_t);
char *info_filesys;
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index e8a6d82ae7f..efb746fc6a2 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.c,v 1.19 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass1.c,v 1.20 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: pass1.c,v 1.19 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass1.c,v 1.20 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -59,9 +59,9 @@ static void checkinode(ino_t, struct inodesc *);
static ino_t info_inumber;
static int
-pass1_info(char *buf)
+pass1_info(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 1, inode %d/%d",
+ return (snprintf(buf, buflen, "phase 1, inode %d/%d",
info_inumber, sblock.fs_ipg * sblock.fs_ncg) > 0);
}
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index b54a1fa469c..4224ae2fa2e 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1b.c,v 1.12 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass1b.c,v 1.13 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass1b.c,v 1.10 1996/09/23 16:18:37 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass1b.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: pass1b.c,v 1.12 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass1b.c,v 1.13 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -54,9 +54,9 @@ static struct dups *duphead;
static ino_t info_inumber;
static int
-pass1b_info(char *buf)
+pass1b_info(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 1b, inode %d/%d",
+ return (snprintf(buf, buflen, "phase 1b, inode %d/%d",
info_inumber, sblock.fs_ipg * sblock.fs_ncg) > 0);
}
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 2b4b33dcfd6..4a235958288 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass2.c,v 1.24 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass2.c,v 1.25 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass2.c 8.6 (Berkeley) 10/27/94";
#else
-static const char rcsid[] = "$OpenBSD: pass2.c,v 1.24 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass2.c,v 1.25 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -61,16 +61,16 @@ static int info_max;
static int info_pos;
static int
-pass2_info1(char *buf)
+pass2_info1(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 2, directory %d/%d",
+ return (snprintf(buf, buflen, "phase 2, directory %d/%d",
info_pos, info_max) > 0);
}
static int
-pass2_info2(char *buf)
+pass2_info2(char *buf, size_t buflen)
{
- if (asprintf(&buf, "phase 2, parent directory %d/%d",
+ if (snprintf(buf, buflen, "phase 2, parent directory %d/%d",
info_pos, info_max) > 0)
return (strlen(buf));
return (0);
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
index 3fa2e6b9a18..70cf4cecaa4 100644
--- a/sbin/fsck_ffs/pass3.c
+++ b/sbin/fsck_ffs/pass3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass3.c,v 1.11 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass3.c,v 1.12 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass3.c,v 1.8 1995/03/18 14:55:54 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: pass3.c,v 1.11 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass3.c,v 1.12 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -49,9 +49,9 @@ static const char rcsid[] = "$OpenBSD: pass3.c,v 1.11 2006/03/12 02:28:28 deraad
static int info_pos;
static int
-pass3_info(char *buf)
+pass3_info(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 3, directory %d/%ld",
+ return (snprintf(buf, buflen, "phase 3, directory %d/%ld",
info_pos, inplast) > 0);
}
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index 644d87483d9..cadcf9847d0 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass4.c,v 1.14 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass4.c,v 1.15 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass4.c,v 1.11 1996/09/27 22:45:17 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: pass4.c,v 1.14 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass4.c,v 1.15 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -53,9 +53,9 @@ static const char rcsid[] = "$OpenBSD: pass4.c,v 1.14 2006/03/12 02:28:28 deraad
static ino_t info_inumber;
static int
-pass4_info(char *buf)
+pass4_info(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 4, inode %d/%d",
+ return (snprintf(buf, buflen, "phase 4, inode %d/%d",
info_inumber, lastino) > 0);
}
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 5607605a8dd..450eb917d1e 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass5.c,v 1.22 2006/03/12 02:28:28 deraadt Exp $ */
+/* $OpenBSD: pass5.c,v 1.23 2006/03/22 20:24:32 deraadt Exp $ */
/* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass5.c 8.6 (Berkeley) 11/30/94";
#else
-static const char rcsid[] = "$OpenBSD: pass5.c,v 1.22 2006/03/12 02:28:28 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pass5.c,v 1.23 2006/03/22 20:24:32 deraadt Exp $";
#endif
#endif /* not lint */
@@ -58,9 +58,9 @@ static int info_cg;
static int info_maxcg;
static int
-pass5_info(char *buf)
+pass5_info(char *buf, size_t buflen)
{
- return (asprintf(&buf, "phase 5, cg %d/%d",
+ return (snprintf(buf, buflen, "phase 5, cg %d/%d",
info_cg, info_maxcg) > 0);
}
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;
}