diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-03-12 02:28:29 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-03-12 02:28:29 +0000 |
commit | 021463d27314b0a940efed9c675ef6e20524351e (patch) | |
tree | acf44ed3bc935d6ccdea89d2e3149087619a3587 /sbin | |
parent | 0e3d25eced22fb17f731f8c0ed934b98906ec181 (diff) |
use asprintf instead of a static buffer; dhill, tested by pedro
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 4 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1b.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass2.c | 12 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass3.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass4.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 8 | ||||
-rw-r--r-- | sbin/fsck_ffs/utilities.c | 12 |
8 files changed, 35 insertions, 33 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index c6575bf737c..7ca2bf34f67 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.14 2003/09/25 04:19:39 deraadt Exp $ */ +/* $OpenBSD: fsck.h,v 1.15 2006/03/12 02:28:28 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); +int (*info_fn)(char *); char *info_filesys; diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index f2ae3eca02b..e8a6d82ae7f 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.18 2005/12/19 15:18:01 pedro Exp $ */ +/* $OpenBSD: pass1.c,v 1.19 2006/03/12 02:28:28 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.18 2005/12/19 15:18:01 pedro Exp $"; +static const char rcsid[] = "$OpenBSD: pass1.c,v 1.19 2006/03/12 02:28:28 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, int buflen) +pass1_info(char *buf) { - return (snprintf(buf, buflen, "phase 1, inode %d/%d", + return (asprintf(&buf, "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 71b0844a65f..b54a1fa469c 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1b.c,v 1.11 2005/04/16 18:15:41 millert Exp $ */ +/* $OpenBSD: pass1b.c,v 1.12 2006/03/12 02:28:28 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.11 2005/04/16 18:15:41 millert Exp $"; +static const char rcsid[] = "$OpenBSD: pass1b.c,v 1.12 2006/03/12 02:28:28 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, int buflen) +pass1b_info(char *buf) { - return (snprintf(buf, buflen, "phase 1b, inode %d/%d", + return (asprintf(&buf, "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 471021da924..2b4b33dcfd6 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.23 2006/01/25 06:25:46 tedu Exp $ */ +/* $OpenBSD: pass2.c,v 1.24 2006/03/12 02:28:28 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.23 2006/01/25 06:25:46 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass2.c,v 1.24 2006/03/12 02:28:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -61,16 +61,16 @@ static int info_max; static int info_pos; static int -pass2_info1(char *buf, int buflen) +pass2_info1(char *buf) { - return (snprintf(buf, buflen, "phase 2, directory %d/%d", + return (asprintf(&buf, "phase 2, directory %d/%d", info_pos, info_max) > 0); } static int -pass2_info2(char *buf, int buflen) +pass2_info2(char *buf) { - if (snprintf(buf, buflen, "phase 2, parent directory %d/%d", + if (asprintf(&buf, "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 75f7b34b144..3fa2e6b9a18 100644 --- a/sbin/fsck_ffs/pass3.c +++ b/sbin/fsck_ffs/pass3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass3.c,v 1.10 2005/04/16 18:15:41 millert Exp $ */ +/* $OpenBSD: pass3.c,v 1.11 2006/03/12 02:28:28 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.10 2005/04/16 18:15:41 millert Exp $"; +static const char rcsid[] = "$OpenBSD: pass3.c,v 1.11 2006/03/12 02:28:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -49,9 +49,9 @@ static const char rcsid[] = "$OpenBSD: pass3.c,v 1.10 2005/04/16 18:15:41 miller static int info_pos; static int -pass3_info(char *buf, int buflen) +pass3_info(char *buf) { - return (snprintf(buf, buflen, "phase 3, directory %d/%ld", + return (asprintf(&buf, "phase 3, directory %d/%ld", info_pos, inplast) > 0); } diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c index 53103beab74..644d87483d9 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.13 2006/01/25 06:25:46 tedu Exp $ */ +/* $OpenBSD: pass4.c,v 1.14 2006/03/12 02:28:28 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.13 2006/01/25 06:25:46 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass4.c,v 1.14 2006/03/12 02:28:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -53,9 +53,9 @@ static const char rcsid[] = "$OpenBSD: pass4.c,v 1.13 2006/01/25 06:25:46 tedu E static ino_t info_inumber; static int -pass4_info(char *buf, int buflen) +pass4_info(char *buf) { - return (snprintf(buf, buflen, "phase 4, inode %d/%d", + return (asprintf(&buf, "phase 4, inode %d/%d", info_inumber, lastino) > 0); } diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index b8432cc4d61..5607605a8dd 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.21 2006/01/25 06:25:46 tedu Exp $ */ +/* $OpenBSD: pass5.c,v 1.22 2006/03/12 02:28:28 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.21 2006/01/25 06:25:46 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass5.c,v 1.22 2006/03/12 02:28:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -58,9 +58,9 @@ static int info_cg; static int info_maxcg; static int -pass5_info(char *buf, int buflen) +pass5_info(char *buf) { - return (snprintf(buf, buflen, "phase 5, cg %d/%d", + return (asprintf(&buf, "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 f338dd1dae7..735552163f8 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.21 2006/01/25 06:25:46 tedu Exp $ */ +/* $OpenBSD: utilities.c,v 1.22 2006/03/12 02:28:28 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.21 2006/01/25 06:25:46 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: utilities.c,v 1.22 2006/03/12 02:28:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -544,18 +544,18 @@ dofix(struct inodesc *idesc, char *msg) /* NOTREACHED */ } -int (* info_fn)(char *, int) = NULL; +int (* info_fn)(char *) = NULL; char *info_filesys = "?"; void catchinfo(int n) { int save_errno = errno; - char buf[1024]; + char *buf = NULL; struct iovec iov[4]; int fd; - if (info_fn != NULL && info_fn(buf, sizeof buf)) { + if (info_fn != NULL && info_fn(buf)) { fd = open(_PATH_TTY, O_WRONLY); if (fd >= 0) { iov[0].iov_base = info_filesys; @@ -571,6 +571,8 @@ catchinfo(int n) close(fd); } } + if (buf) + free(buf); errno = save_errno; } |