package

simple and robust package manager
Log | Files | Refs | README

commit 44e5dce7d28acf939c0b28d7aeb04067c12d8ddf
parent 0184aa26c1bb05d9d91ac219f1b5e05642964d3f
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 20 Jan 2019 22:17:59 +0100

fix a non-null-terminated buffer in hier.c

Diffstat:
Mhier.c | 1+
Mpackage-add.c | 22+++++++++++++++++++---
Mpackage-dep.c | 10+++++++---
Mpackage-tree.c | 1+
Mpackage.c | 1+
5 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/hier.c b/hier.c @@ -114,6 +114,7 @@ hier_copy_recurse(stralloc *from, stralloc *to, int action) if (!stralloc_cats(to, "/")) return 0; to_n = to->n; + if (!stralloc_cat0(from)) return 0; dp = opendir(from->x); if (!dp) return 0; errno = 0; while ((de = readdir(dp))) { diff --git a/package-add.c b/package-add.c @@ -17,6 +17,22 @@ die_nomem(void) log_fatal_sys_1(100, "malloc"); } +void +log_step(package const *p, char const *step, char const *fmt) +{ + buffer_puts(buffer_1, " "); + buffer_puts(buffer_1, p->dep_download ? "d" : "-"); + buffer_puts(buffer_1, p->dep_build ? "b" : "-"); + buffer_puts(buffer_1, p->dep_lib ? "l" : "-"); + buffer_puts(buffer_1, p->dep_run ? "r" : "-"); + buffer_puts(buffer_1, " "); + buffer_puts(buffer_1, step); + buffer_puts(buffer_1, " "); + buffer_puts(buffer_1, fmt); + buffer_puts(buffer_1, "\n"); + buffer_flush(buffer_1); +} + int get(package const *p, char const *def, char const *pkg) { @@ -34,7 +50,7 @@ get(package const *p, char const *def, char const *pkg) if (!stralloc_cat0(&sa)) die_nomem(); if (stat_isfile(sa.x)) return 0; - log_info_2("package-get ", fmt); + log_step(p, "get ", fmt); return forkexec_wait(argv); } @@ -55,7 +71,7 @@ build(package const *p, char const *def, char const *pkg) if (!stralloc_cat0(&sa)) die_nomem(); if (stat_islink(sa.x)) return 0; - log_info_2("package-build ", fmt); + log_step(p, "build ", fmt); return forkexec_wait(argv); } @@ -67,7 +83,7 @@ install(package const *p, char const *def, char const *pkg, char const *root) fmt[package_fmt(p, fmt)] = '\0'; - log_info_2("package-install ", fmt); + log_step(p, "install", fmt); return forkexec_wait(argv); } diff --git a/package-dep.c b/package-dep.c @@ -30,9 +30,7 @@ main(int argc, char **argv) if (**av == '\0' || (*av)[package_scan(&p, *av, strlen(*av))] != '\0') log_fatal_sys_2(1, "invalid package format: ", *av); if (!package_version(&p, def)) log_fatal_sys_2(101, "version ", p.name); - - if (!package_version(&p, def)) - log_fatal_sys_3(103, "could not get ", *av," version"); + p.dep_run = 1; genalloc_init(&ga); if (!package_dep(&p, &ga, def)) @@ -44,6 +42,12 @@ main(int argc, char **argv) package *p = genalloc_get(&ga, package, i); package_fmt(p, fmt); + buffer_puts(buffer_1, " "); + buffer_puts(buffer_1, p->dep_download ? "d" : "-"); + buffer_puts(buffer_1, p->dep_build ? "b" : "-"); + buffer_puts(buffer_1, p->dep_lib ? "l" : "-"); + buffer_puts(buffer_1, p->dep_run ? "r" : "-"); + buffer_puts(buffer_1, " "); buffer_puts(buffer_1, fmt); buffer_putc(buffer_1, '\n'); } diff --git a/package-tree.c b/package-tree.c @@ -25,6 +25,7 @@ tree(package *p, stralloc *prefix, char const *def) if (!stralloc_cats(prefix, " - ")) goto error; if (!stralloc_cats(prefix, p->ver)) goto error; if (!stralloc_cats(prefix, "/")) goto error; + buffer_puts(buffer_1, " "); buffer_puts(buffer_1, p->dep_download ? "d" : "-"); buffer_puts(buffer_1, p->dep_build ? "b" : "-"); buffer_puts(buffer_1, p->dep_lib ? "l" : "-"); diff --git a/package.c b/package.c @@ -333,6 +333,7 @@ package_dep(package const *p, genalloc *packages, char const *def) } if (r != 0) goto error; } + ret = 1; error: if (fd[0] >= 0) close(fd[0]);