summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 15:26:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 15:26:24 +0000
commit9c9800d4aa82516083bfbda3a38f0cac4944fac5 (patch)
tree24ea2e0f8e18491bf4074d281f96f6a096522c2b /sbin
parentabafa2e8919d40cadcded6b038d3d11944793294 (diff)
more asprintf; ok dhill@mindcry.org
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ccdconfig/ccdconfig.c18
-rw-r--r--sbin/ncheck_ffs/ncheck_ffs.c11
2 files changed, 11 insertions, 18 deletions
diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c
index ec36417f988..01b64936dbb 100644
--- a/sbin/ccdconfig/ccdconfig.c
+++ b/sbin/ccdconfig/ccdconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccdconfig.c,v 1.23 2005/03/29 22:23:42 mickey Exp $ */
+/* $OpenBSD: ccdconfig.c,v 1.24 2005/11/12 15:26:23 deraadt Exp $ */
/* $NetBSD: ccdconfig.c,v 1.6 1996/05/16 07:11:18 thorpej Exp $ */
/*-
@@ -422,7 +422,7 @@ static char *
resolve_ccdname(char *name)
{
char c, *path;
- size_t len, newlen;
+ size_t len;
int rawpart;
if (name[0] == '/' || name[0] == '.') {
@@ -433,19 +433,17 @@ resolve_ccdname(char *name)
len = strlen(name);
c = name[len - 1];
- newlen = len + 8;
- if ((path = malloc(newlen)) == NULL)
- return (NULL);
- memset(path, 0, newlen);
-
if (isdigit(c)) {
if ((rawpart = getrawpartition()) < 0) {
free(path);
return (NULL);
}
- (void)snprintf(path, newlen, "/dev/%s%c", name, 'a' + rawpart);
- } else
- (void)snprintf(path, newlen, "/dev/%s", name);
+ if (asprintf(&path, "/dev/%s%c", name, 'a' + rawpart) == -1)
+ return (NULL);
+ } else {
+ if (asprintf(&path, "/dev/%s", name) == -1)
+ return (NULL);
+ }
return (path);
}
diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c
index 28d8a1b0e39..93ecf017de0 100644
--- a/sbin/ncheck_ffs/ncheck_ffs.c
+++ b/sbin/ncheck_ffs/ncheck_ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncheck_ffs.c,v 1.24 2005/04/12 06:39:29 deraadt Exp $ */
+/* $OpenBSD: ncheck_ffs.c,v 1.25 2005/11/12 15:26:23 deraadt Exp $ */
/*-
* Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.24 2005/04/12 06:39:29 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.25 2005/11/12 15:26:23 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -385,18 +385,13 @@ searchdir(ino_t ino, daddr_t blkno, long size, long filesize,
}
}
if (mode == IFDIR) {
- int len;
-
if (dp->d_name[0] == '.') {
if (dp->d_name[1] == '\0' ||
(dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
continue;
}
- len = strlen(path) + strlen(dp->d_name) + 2;
- npath = malloc(len);
- if (npath == NULL)
+ if (asprintf(&npath, "%s/%s", path, dp->d_name) == -1)
errx(1, "malloc");
- snprintf(npath, len, "%s/%s", path, dp->d_name);
scanonedir(dp->d_ino, npath);
free(npath);
}