pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit 40a21ff7404aca7885609396c77a85216b3cf895
parent 767955d994347cf26faf168ebffc73bd3f3584f8
Author: z3bra <willyatmailoodotorg>
Date:   Mon Jan  4 17:29:57 2016

Fix uninitialized values

Diffstat:
 pm.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/pm.c b/pm.c @@ -101,7 +101,7 @@ is_empty(char *dir) int mkdir_parents(char *dir, mode_t mode) { - char tmp[PATH_MAX]; + char tmp[PATH_MAX] = ""; char *p = NULL; size_t len; @@ -187,7 +187,7 @@ int list_content(int fd, char *name) { int meta; - char tmp[PATH_MAX]; + char tmp[PATH_MAX] = ""; snprintf(tmp, PATH_MAX, "%s/%s/files", PACKAGE_DATA, name); if ((meta = open(tmp, O_RDONLY)) < 0) { @@ -210,7 +210,7 @@ list_local(int fd, char *datadir) { DIR *d; struct dirent *p; - char tmp[PATH_MAX]; + char tmp[PATH_MAX] = ""; int meta; size_t len; @@ -412,15 +412,17 @@ unpack(char *root, char *in) int delete_content(FILE *f) { - char file[PATH_MAX]; + char file[PATH_MAX] = ""; struct stat st; - size_t len; + size_t len = 0; if (fgets(file, PATH_MAX, f)) delete_content(f); /* remove trailing '\n' */ - len = strnlen(file, PATH_MAX); + if ((len = strnlen(file, PATH_MAX)) == 0) + return -1; + file[len - 1] = 0; len--; @@ -471,6 +473,7 @@ delete(const char *datadir, const char *rootfs, const char *name) /* hack again */ chdir(cwd); + free(cwd); unlink(meta); @@ -486,7 +489,7 @@ pack_load_file(char *path) { int fd; struct pack *pack = malloc(sizeof(struct pack)); - char tmp[PATH_MAX]; + char tmp[PATH_MAX] = ""; char *p; if ((fd = open(path, O_RDONLY)) < 0) {