From c238a97a9e90734da15163ba54d6862bb8e360e9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 25 Apr 2005 05:24:35 +0000 Subject: use asprintf in place of malloc/sprintf as suggested by solar --- e2fsprogs/chattr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'e2fsprogs/chattr.c') diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c index 5aaa14fbb..07cee8f7c 100644 --- a/e2fsprogs/chattr.c +++ b/e2fsprogs/chattr.c @@ -167,11 +167,9 @@ static int chattr_dir_proc(const char *dir_name, struct dirent *de, /*if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {*/ if (de->d_name[0] == '.' && (de->d_name[1] == '\0' || \ (de->d_name[1] == '.' && de->d_name[2] == '\0'))) { - - char *path = malloc(strlen(dir_name) + 1 + strlen(de->d_name) + 1); - if (!path) - bb_error_msg_and_die("Couldn't allocate path variable in chattr_dir_proc"); - sprintf(path, "%s/%s", dir_name, de->d_name); + char *path; + if (asprintf(&path, "%s/%s", dir_name, de->d_name) == -1) + bb_error_msg_and_die("asprintf failed"); change_attributes(path); free(path); } -- cgit v1.2.3