commit: 749ad1d7d40276594a2bb69c4d71da33b6abecbd Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Fri Jan 31 14:43:48 2020 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Fri Jan 31 14:43:48 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=749ad1d7
qsize: solve theoretical key conflict for dev/inode Jan Ziak pointed out that it is possible to generate the same key for two different files. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qsize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qsize.c b/qsize.c index e54f714..c78a35f 100644 --- a/qsize.c +++ b/qsize.c @@ -112,7 +112,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv) uint64_t num_bytes; struct stat st; bool ok = false; - char ikey[2 * (sizeof(size_t) * 2) + 1]; /* hex rep */ + char ikey[2 * (sizeof(size_t) * 2) + 1 + 1]; /* hex rep */ size_t cur_uniq = cnt_set(state->uniq_files); bool isuniq; @@ -143,7 +143,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv) if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW) == 0) { - snprintf(ikey, sizeof(ikey), "%zx%zx", + snprintf(ikey, sizeof(ikey), "%zx:%zx", (size_t)st.st_dev, (size_t)st.st_ino); state->uniq_files = add_set_unique(ikey, state->uniq_files, &isuniq);