diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-16 17:37:26 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-16 17:37:26 +0000 |
commit | 306d2c85cf362a9041b81c448dd0d093d1b05585 (patch) | |
tree | 8ea1d711f1f91e344aeb42783ea780f3acf75b69 /sbin | |
parent | 9ece674622a863eb59f1b51f503bf9e5cea2b24f (diff) |
while snprintf and strlcpy and strlcat have this nice >buflen API (and the
-1 mess as well), it is probably not wise to make other functions do the same
thing. make them return strlen(). ok uwe marco
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1b.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass2.c | 16 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass3.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass4.c | 10 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 9 |
6 files changed, 40 insertions, 25 deletions
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 0f0fcfd7e56..cb59f878992 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.15 2003/10/11 01:43:45 tedu Exp $ */ +/* $OpenBSD: pass1.c,v 1.16 2005/04/16 17:37:25 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.15 2003/10/11 01:43:45 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass1.c,v 1.16 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -61,8 +61,10 @@ static ino_t info_inumber; static int pass1_info(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 1, inode %d/%d", - info_inumber, sblock.fs_ipg * sblock.fs_ncg); + if (snprintf(buf, buflen, "phase 1, inode %d/%d", + info_inumber, sblock.fs_ipg * sblock.fs_ncg) > 0) + return (strlen(buf)); + return (0); } void diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c index 552528d6c6e..4fc37aff9f1 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1b.c,v 1.9 2003/08/25 23:28:15 tedu Exp $ */ +/* $OpenBSD: pass1b.c,v 1.10 2005/04/16 17:37:25 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.9 2003/08/25 23:28:15 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass1b.c,v 1.10 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -56,8 +56,10 @@ static ino_t info_inumber; static int pass1b_info(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 1b, inode %d/%d", - info_inumber, sblock.fs_ipg * sblock.fs_ncg); + if (snprintf(buf, buflen, "phase 1b, inode %d/%d", + info_inumber, sblock.fs_ipg * sblock.fs_ncg) > 0) + return (strlen(buf)); + return (0); } void diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index 83e2a14443c..7cc10c245f3 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.19 2003/10/11 01:43:45 tedu Exp $ */ +/* $OpenBSD: pass2.c,v 1.20 2005/04/16 17:37:25 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.19 2003/10/11 01:43:45 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass2.c,v 1.20 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -63,15 +63,19 @@ static int info_pos; static int pass2_info1(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 2, directory %d/%d", - info_pos, info_max); + if (snprintf(buf, buflen, "phase 2, directory %d/%d", + info_pos, info_max) > 0) + return (strlen(buf)); + return (0); } static int pass2_info2(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 2, parent directory %d/%d", - info_pos, info_max); + if (snprintf(buf, buflen, "phase 2, parent directory %d/%d", + info_pos, info_max) > 0) + return (strlen(buf)); + return (0); } void diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c index 881abc28b9b..7460685d197 100644 --- a/sbin/fsck_ffs/pass3.c +++ b/sbin/fsck_ffs/pass3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass3.c,v 1.8 2003/06/02 20:06:15 millert Exp $ */ +/* $OpenBSD: pass3.c,v 1.9 2005/04/16 17:37:25 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.8 2003/06/02 20:06:15 millert Exp $"; +static const char rcsid[] = "$OpenBSD: pass3.c,v 1.9 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -51,8 +51,10 @@ static int info_pos; static int pass3_info(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 3, directory %d/%ld", - info_pos, inplast); + if (snprintf(buf, buflen, "phase 3, directory %d/%ld", + info_pos, inplast) > 0) + return (strlen(buf)); + return (0); } void diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c index 5fc80780f7a..b7d2249e964 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.10 2003/10/11 01:43:45 tedu Exp $ */ +/* $OpenBSD: pass4.c,v 1.11 2005/04/16 17:37:25 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.10 2003/10/11 01:43:45 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass4.c,v 1.11 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -55,8 +55,10 @@ static ino_t info_inumber; static int pass4_info(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 4, inode %d/%d", - info_inumber, lastino); + if (snprintf(buf, buflen, "phase 4, inode %d/%d", + info_inumber, lastino) > 0) + return (strlen(buf)); + return (0); } void diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 504a0dfcbbb..e098b3d9076 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.17 2003/10/11 01:43:45 tedu Exp $ */ +/* $OpenBSD: pass5.c,v 1.18 2005/04/16 17:37:25 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.17 2003/10/11 01:43:45 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: pass5.c,v 1.18 2005/04/16 17:37:25 deraadt Exp $"; #endif #endif /* not lint */ @@ -60,7 +60,10 @@ static int info_maxcg; static int pass5_info(char *buf, int buflen) { - return snprintf(buf, buflen, "phase 5, cg %d/%d", info_cg, info_maxcg); + if (snprintf(buf, buflen, "phase 5, cg %d/%d", + info_cg, info_maxcg) > 0) + return (strlen(buf)); + return (0); } void |