Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bb4f1b9
lib: cleanup errors
Duncaen Feb 26, 2026
038c184
bin/xbps-query: cleanup error returns
Duncaen Feb 26, 2026
0540d4d
bin/xbps-rindex: cleanup error returns
Duncaen Feb 26, 2026
37786a4
bin/xbps-rindex: do not remove pkgname property
Duncaen Feb 26, 2026
80d37ef
lib: do not remove pkgname property when storing in pkgdb
Duncaen Feb 26, 2026
a63ff55
bin/xbps-create: fix memory leak
Duncaen Feb 26, 2026
bca5f23
lib: fix memory leak in files check
Duncaen Feb 26, 2026
f0e03d1
lib: fix memory leak when unpacking updates
Duncaen Feb 26, 2026
a4e87fe
bin/xbps-create: fix memory leak in alternatives processing
Duncaen Feb 26, 2026
8341c22
bin/xbps-install: fix memory leak in package list printing
Duncaen Feb 26, 2026
64d7aa0
lib: partially fix memory leak from xbps_get_pkg_fulldeptree
Duncaen Feb 26, 2026
8b8fc7a
lib: fix memory leak in conflict string generation
Duncaen Feb 26, 2026
be5af8e
bin/xbps-query: fix memory leak in --dependencies
Duncaen Feb 26, 2026
fc47586
bin/xbps-query: fix memory leak in --files
Duncaen Feb 26, 2026
95f8791
lib: fix memory leak in xbps_transaction_store
Duncaen Feb 26, 2026
d748e3e
lib: replace assert with error check in xbps_conf_init
Duncaen Feb 26, 2026
68e4157
lib: free memory from xbps_handle in xbps_end
Duncaen Feb 26, 2026
dac15d1
tests: fix memory leaks in config tests
Duncaen Feb 26, 2026
59da1bc
tests: fix memory leaks in c tests
Duncaen Feb 26, 2026
d94dcbe
lib: fix memory leak in shlib check error messages
Duncaen Feb 26, 2026
c1cf1c7
lib: cleanup includes
Duncaen Feb 26, 2026
8b48ba4
lib: xbps_find_pkg_orphans handle memory errors
Duncaen Feb 26, 2026
4db63d6
lib: do not call qsort with NULL
Duncaen Feb 26, 2026
04f0083
bin/xbps-fbulk: handle fopen/popen failures
Duncaen Feb 26, 2026
a454abb
bin/xbps-uhelper: initialize struct xbps_handle directly
Duncaen Feb 26, 2026
e836f2e
lib: fix xbps_pkgdb_update error return on ENOMEM
Duncaen Feb 26, 2026
8a59fcf
bin/xbps-install: initialize struct xbps_handle directly
Duncaen Feb 27, 2026
637f415
tests: add two test cases for orphan removal
Duncaen Feb 27, 2026
8e43b62
lib: error handling and cleanup of xbps_transaction_store
Duncaen Feb 27, 2026
99756d1
lib: cleanup transaction_store and handle errors
Duncaen Feb 27, 2026
7ccac65
lib: make xbps_transaction_pkg_type_set private
Duncaen Feb 27, 2026
7f63462
tests: cleanup xbps-query search prop test
Duncaen Feb 28, 2026
a48ba70
tests: cleanup some replaces tests
Duncaen Feb 28, 2026
f8052c5
lib: add replace arg to transaction_store
Duncaen Feb 28, 2026
22ea541
lib: cleanup transaction_check_replaces
Duncaen Feb 28, 2026
e99b0a2
lib: remove unused xbps_array_replace_dict_* functions
Duncaen Feb 28, 2026
fb126a3
run-tests: allow passing specific tests to run
Duncaen Feb 28, 2026
48bc7f9
bin/xbps-query: only release dep array if its generated (fulldeptree)
Duncaen Mar 2, 2026
4501b21
bin/xbps-query: only release revdeps in repomode
Duncaen Mar 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions bin/xbps-create/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,19 @@ process_one_alternative(const char *altgrname, const char *val)
xbps_dictionary_t d;
xbps_array_t a;
const char *altfiles;
bool alloc = false;
bool alloc_dict = false, alloc_array = false;

if ((d = xbps_dictionary_get(pkg_propsd, "alternatives")) == NULL) {
d = xbps_dictionary_create();
if (d == NULL)
die("xbps_dictionary_create");
alloc = true;
alloc_dict = true;
}
if ((a = xbps_dictionary_get(d, altgrname)) == NULL) {
a = xbps_array_create();
if (a == NULL)
die("xbps_array_create");
alloc_array = true;
}
altfiles = strchr(val, ':');
if (!altfiles)
Expand All @@ -258,10 +259,10 @@ process_one_alternative(const char *altgrname, const char *val)
xbps_dictionary_set(d, altgrname, a);
xbps_dictionary_set(pkg_propsd, "alternatives", d);

if (alloc) {
if (alloc_array)
xbps_object_release(a);
if (alloc_dict)
xbps_object_release(d);
}
}


Expand Down Expand Up @@ -843,14 +844,13 @@ process_archive(struct archive *ar,
/* Add all package data files and release resources */
while ((xe = TAILQ_FIRST(&xentry_list)) != NULL) {
TAILQ_REMOVE(&xentry_list, xe, entries);
if (xe->type == ENTRY_TYPE_METADATA || xe->type == ENTRY_TYPE_DIRS)
continue;

if (!quiet) {
printf("%s: adding `%s' ...\n", pkgver, xe->file);
fflush(stdout);
if (xe->type != ENTRY_TYPE_METADATA && xe->type != ENTRY_TYPE_DIRS) {
if (!quiet) {
printf("%s: adding `%s' ...\n", pkgver, xe->file);
fflush(stdout);
}
process_entry_file(ar, resolver, xe, NULL);
}
process_entry_file(ar, resolver, xe, NULL);
free(xe->file);
free(xe->target);
free(xe);
Expand Down
24 changes: 23 additions & 1 deletion bin/xbps-fbulk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ processCompletion(struct item *item)
logpath = xbps_xasprintf("%s/deps/%s.txt",
LogDir, xitem->pkgn);
fp = fopen(logpath, "a");
if (!fp) {
xbps_error_printf(
"failed to open file: %s: %s\n",
logpath, strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp, "%s\n", item->pkgn);
fclose(fp);
free(logpath);
Expand Down Expand Up @@ -369,7 +375,13 @@ runBuilds(const char *bpath)
*/
item->xcode = -98;
fp = fopen(logpath, "a");
xbps_error_printf("xbps-fbulk: unable to fork/exec xbps-src\n");
if (!fp) {
xbps_error_printf(
"failed to open file: %s: %s\n",
logpath, strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp, "xbps-fbulk: unable to fork/exec xbps-src\n");
fclose(fp);
processCompletion(item);
} else {
Expand Down Expand Up @@ -426,6 +438,12 @@ addDepn(struct item *item, struct item *xitem)
logpath = xbps_xasprintf("%s/deps/%s.txt",
LogDir, item->pkgn);
fp = fopen(logpath, "a");
if (!fp) {
xbps_error_printf(
"failed to open file: %s: %s\n", logpath,
strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp, "%s\n", xitem->pkgn);
fclose(fp);
free(logpath);
Expand Down Expand Up @@ -461,6 +479,10 @@ ordered_depends(const char *bpath, const char *pkgn)
snprintf(cmd, sizeof(cmd)-1,
"%s/xbps-src show-build-deps %s 2>&1", bpath, pkgn);
fp = popen(cmd, "r");
if (!fp) {
xbps_error_printf("failed to run xbps-src show-build-deps\n");
exit(EXIT_FAILURE);
}
while (fgets(buf, sizeof(buf), fp) != NULL) {
char dpath[PATH_MAX];
size_t len;
Expand Down
46 changes: 17 additions & 29 deletions bin/xbps-install/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,59 +122,54 @@ main(int argc, char **argv)
{ "staging", no_argument, NULL, 2 },
{ NULL, 0, NULL, 0 }
};
struct xbps_handle xh;
struct xbps_handle xh = {0};
struct xferstat xfer;
const char *rootdir, *cachedir, *confdir;
int i, c, flags, rv, fflag = 0;
int i, c, rv, fflag = 0;
bool syncf, yes, force, drun, update;
int maxcols, eexist = 0;

rootdir = cachedir = confdir = NULL;
flags = rv = 0;
syncf = yes = force = drun = update = false;

memset(&xh, 0, sizeof(xh));

while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (c) {
case 1:
flags |= XBPS_FLAG_INSTALL_REPRO;
xh.flags |= XBPS_FLAG_INSTALL_REPRO;
break;
case 2:
flags |= XBPS_FLAG_USE_STAGE;
xh.flags |= XBPS_FLAG_USE_STAGE;
break;
case 'A':
flags |= XBPS_FLAG_INSTALL_AUTO;
xh.flags |= XBPS_FLAG_INSTALL_AUTO;
break;
case 'C':
confdir = optarg;
xbps_strlcpy(xh.confdir, optarg, sizeof(xh.confdir));
break;
case 'c':
cachedir = optarg;
xbps_strlcpy(xh.cachedir, optarg, sizeof(xh.cachedir));
break;
case 'd':
flags |= XBPS_FLAG_DEBUG;
xh.flags |= XBPS_FLAG_DEBUG;
break;
case 'D':
flags |= XBPS_FLAG_DOWNLOAD_ONLY;
xh.flags |= XBPS_FLAG_DOWNLOAD_ONLY;
break;
case 'f':
fflag++;
if (fflag > 1)
flags |= XBPS_FLAG_FORCE_UNPACK;
xh.flags |= XBPS_FLAG_FORCE_UNPACK;
force = true;
break;
case 'h':
usage(false);
/* NOTREACHED */
case 'I':
flags |= XBPS_FLAG_IGNORE_FILE_CONFLICTS;
xh.flags |= XBPS_FLAG_IGNORE_FILE_CONFLICTS;
break;
case 'i':
flags |= XBPS_FLAG_IGNORE_CONF_REPOS;
xh.flags |= XBPS_FLAG_IGNORE_CONF_REPOS;
break;
case 'M':
flags |= XBPS_FLAG_REPOS_MEMSYNC;
xh.flags |= XBPS_FLAG_REPOS_MEMSYNC;
break;
case 'n':
drun = true;
Expand All @@ -183,19 +178,19 @@ main(int argc, char **argv)
xbps_repo_store(&xh, optarg);
break;
case 'r':
rootdir = optarg;
xbps_strlcpy(xh.rootdir, optarg, sizeof(xh.rootdir));
break;
case 'S':
syncf = true;
break;
case 'U':
flags |= XBPS_FLAG_UNPACK_ONLY;
xh.flags |= XBPS_FLAG_UNPACK_ONLY;
break;
case 'u':
update = true;
break;
case 'v':
flags |= XBPS_FLAG_VERBOSE;
xh.flags |= XBPS_FLAG_VERBOSE;
break;
case 'V':
printf("%s\n", XBPS_RELVER);
Expand All @@ -218,14 +213,7 @@ main(int argc, char **argv)
xh.state_cb = state_cb;
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
if (rootdir)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;
if (flags & XBPS_FLAG_VERBOSE)
if (xh.flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb;

if ((rv = xbps_init(&xh)) != 0) {
Expand Down
45 changes: 24 additions & 21 deletions bin/xbps-install/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,51 +132,54 @@ show_dry_run_actions(struct transaction *trans)
}

static void
show_package_list(struct transaction *trans, xbps_trans_type_t ttype, unsigned int cols)
show_package_list(struct transaction *trans, xbps_trans_type_t list_type, unsigned int cols)
{
xbps_dictionary_t ipkgd;
char buf[1024];
xbps_object_t obj;
xbps_trans_type_t tt;
const char *pkgver, *pkgname, *ipkgver, *version, *iversion;
char *buf = NULL;

while ((obj = xbps_object_iterator_next(trans->iter)) != NULL) {
xbps_trans_type_t tt;
const char *pkgver = NULL, *pkgname = NULL;
bool dload = false;

pkgver = ipkgver = version = iversion = NULL;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
xbps_dictionary_get_bool(obj, "download", &dload);
if (ttype == XBPS_TRANS_DOWNLOAD && dload) {
if (list_type == XBPS_TRANS_DOWNLOAD && dload) {
tt = XBPS_TRANS_DOWNLOAD;
} else {
tt = xbps_transaction_pkg_type(obj);
if (ttype == XBPS_TRANS_INSTALL && tt == XBPS_TRANS_REINSTALL) {
if (list_type == XBPS_TRANS_INSTALL && tt == XBPS_TRANS_REINSTALL) {
tt = XBPS_TRANS_INSTALL;
}
}

buf = NULL;
if (tt != list_type)
continue;

if (tt == XBPS_TRANS_UPDATE) {
/* get installed pkgver */
xbps_dictionary_t ipkgd;
const char *version = NULL, *iversion = NULL, *ipkgver = NULL;
int l;

ipkgd = xbps_pkgdb_get_pkg(trans->xhp, pkgname);
assert(ipkgd);
xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
if (!ipkgd)
xbps_unreachable();
if (!xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver))
xbps_unreachable();
version = xbps_pkg_version(pkgver);
if (!version)
xbps_unreachable();
iversion = xbps_pkg_version(ipkgver);
if (!iversion)
xbps_unreachable();
buf = xbps_xasprintf("%s (%s -> %s)", pkgname, iversion, version);
}
if (ttype == tt) {
if (buf) {
print_package_line(buf, cols, false);
free(buf);
} else {
print_package_line(pkgver, cols, false);
}
l = snprintf(buf, sizeof(buf), "%s (%s -> %s)", pkgname,
iversion, version);
if (l < 0 || (size_t)l >= sizeof(buf))
xbps_unreachable();
print_package_line(buf, cols, false);
} else {
print_package_line(pkgver, cols, false);
}
}
xbps_object_iterator_reset(trans->iter);
Expand Down
15 changes: 9 additions & 6 deletions bin/xbps-query/ownedby.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ repo_match_cb(struct xbps_handle *xhp,

r = xbps_pkg_path_or_url(xhp, bfile, sizeof(bfile), obj);
if (r < 0) {
xbps_error_printf("could not get package path: %s\n", strerror(-r));
return -r;
return xbps_error_errno(
r, "could not get package path: %s\n", strerror(-r));
}
errno = 0;
filesd = xbps_archive_fetch_plist(bfile, "/files.plist");
if (!filesd) {
xbps_error_printf("%s: couldn't fetch files.plist from %s: %s\n",
pkgver, bfile, strerror(errno));
return EINVAL;
if (errno == 0)
errno = EINVAL;
return xbps_error_errno(errno,
"%s: couldn't fetch files.plist from %s: %s\n", pkgver,
bfile, strerror(errno));
}
files_keys = xbps_dictionary_all_keys(filesd);
for (unsigned int i = 0; i < xbps_array_count(files_keys); i++) {
Expand All @@ -175,7 +178,7 @@ repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED)

ffd->repouri = repo->uri;
allkeys = xbps_dictionary_all_keys(repo->idx);
rv = xbps_array_foreach_cb_multi(repo->xhp, allkeys, repo->idx, repo_match_cb, ffd);
rv = -xbps_array_foreach_cb_multi(repo->xhp, allkeys, repo->idx, repo_match_cb, ffd);
xbps_object_release(allkeys);

return rv;
Expand Down
4 changes: 2 additions & 2 deletions bin/xbps-query/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ search_cb(struct xbps_handle *xhp UNUSED, xbps_object_t pkgd,
abort();

if (!xbps_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc)) {
xbps_error_printf("%s: missing short_desc property\n", pkgver);
return -EINVAL;
return xbps_error_errno(
EINVAL, "%s: missing short_desc property\n", pkgver);
}

if (ctx->repo_mode && xbps_match_virtual_pkg_in_dict(pkgd, ctx->pattern))
Expand Down
5 changes: 4 additions & 1 deletion bin/xbps-query/show-deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool repomode, bool
xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep);
puts(pkgdep);
}
if (full)
xbps_object_release(rdeps);
return 0;
}

Expand All @@ -84,6 +86,7 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg, bool repomode)
xbps_array_get_cstring_nocopy(revdeps, i, &pkgdep);
puts(pkgdep);
}
xbps_object_release(revdeps);
if (repomode)
xbps_object_release(revdeps);
return 0;
}
12 changes: 6 additions & 6 deletions bin/xbps-query/show-info-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
int
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg)
{
xbps_dictionary_t d;
xbps_dictionary_t filesd;
int rv = 0;

d = xbps_pkgdb_get_pkg_files(xhp, pkg);
if (d == NULL)
filesd = xbps_pkgdb_get_pkg_files(xhp, pkg);
if (filesd == NULL)
return ENOENT;

rv = show_pkg_files(d);

rv = show_pkg_files(filesd);
xbps_object_release(filesd);
return rv;
}

Expand Down Expand Up @@ -341,7 +341,7 @@ repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)

filesd = xbps_archive_fetch_plist(bfile, "/files.plist");
if (filesd == NULL) {
if (errno != ENOTSUP && errno != ENOENT) {
if (errno != ENOTSUP && errno != ENOENT) {
xbps_error_printf("Unexpected error: %s\n", strerror(errno));
}
return errno;
Expand Down
1 change: 0 additions & 1 deletion bin/xbps-rindex/index-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ index_add_pkg(struct xbps_handle *xhp, xbps_dictionary_t index, xbps_dictionary_
if (!xbps_dictionary_set_uint64(binpkgd, "filename-size", (uint64_t)st.st_size))
goto err_errno;

xbps_dictionary_remove(binpkgd, "pkgname");
xbps_dictionary_remove(binpkgd, "version");
xbps_dictionary_remove(binpkgd, "packaged-with");

Expand Down
Loading
Loading