Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Fri, 31 Jan 2020 14:45:50
Message-Id: 1580481828.749ad1d7d40276594a2bb69c4d71da33b6abecbd.grobian@gentoo
1 commit: 749ad1d7d40276594a2bb69c4d71da33b6abecbd
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 31 14:43:48 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 31 14:43:48 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=749ad1d7
7
8 qsize: solve theoretical key conflict for dev/inode
9
10 Jan Ziak pointed out that it is possible to generate the same key for
11 two different files.
12
13 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
14
15 qsize.c | 4 ++--
16 1 file changed, 2 insertions(+), 2 deletions(-)
17
18 diff --git a/qsize.c b/qsize.c
19 index e54f714..c78a35f 100644
20 --- a/qsize.c
21 +++ b/qsize.c
22 @@ -112,7 +112,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
23 uint64_t num_bytes;
24 struct stat st;
25 bool ok = false;
26 - char ikey[2 * (sizeof(size_t) * 2) + 1]; /* hex rep */
27 + char ikey[2 * (sizeof(size_t) * 2) + 1 + 1]; /* hex rep */
28 size_t cur_uniq = cnt_set(state->uniq_files);
29 bool isuniq;
30
31 @@ -143,7 +143,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
32 if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd,
33 e->name + 1, &st, AT_SYMLINK_NOFOLLOW) == 0)
34 {
35 - snprintf(ikey, sizeof(ikey), "%zx%zx",
36 + snprintf(ikey, sizeof(ikey), "%zx:%zx",
37 (size_t)st.st_dev, (size_t)st.st_ino);
38 state->uniq_files =
39 add_set_unique(ikey, state->uniq_files, &isuniq);