Skip to content

Commit 9f2b21c

Browse files
megalonimgeriesa
authored andcommitted
in_tail: Fix 32 bit support in file hash logic
On a 32 bit system, the inode number is 32 bits, not 64, so the format string expecting a 64bit parameter would end up with junk data and continue to think a new file was found, leaking file descriptors and eventually preventing fluent bit from running. Cast the inode parameter when generating the file hash to 64 bits to avoid differences on 32 versus 64 bit systems. Signed-off-by: Megan E. Smith <[email protected]> Signed-off-by: Manal Geries <[email protected]>
1 parent 0b0bc07 commit 9f2b21c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/in_tail/tail_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static int stat_to_hash_bits(struct flb_tail_config *ctx, struct stat *st,
7575
st_dev = stat_get_st_dev(st);
7676

7777
len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64 ":%" PRIu64,
78-
st_dev, st->st_ino);
78+
st_dev, (uint64_t)st->st_ino);
7979

8080
*out_hash = cfl_hash_64bits(tmp, len);
8181
return 0;
@@ -95,7 +95,7 @@ static int stat_to_hash_key(struct flb_tail_config *ctx, struct stat *st,
9595

9696
st_dev = stat_get_st_dev(st);
9797
tmp = flb_sds_printf(&buf, "%" PRIu64 ":%" PRIu64,
98-
st_dev, st->st_ino);
98+
st_dev, (uint64_t)st->st_ino);
9999
if (!tmp) {
100100
flb_sds_destroy(buf);
101101
return -1;
@@ -1794,7 +1794,7 @@ int flb_tail_file_purge(struct flb_input_instance *ins,
17941794
flb_plg_debug(ctx->ins,
17951795
"inode=%"PRIu64" purge rotated file %s " \
17961796
"(offset=%"PRId64" / size = %"PRIu64")",
1797-
file->inode, file->name, file->offset, st.st_size);
1797+
file->inode, file->name, file->offset, (uint64_t)st.st_size);
17981798
if (file->pending_bytes > 0 && flb_input_buf_paused(ins)) {
17991799
flb_plg_warn(ctx->ins, "purged rotated file while data "
18001800
"ingestion is paused, consider increasing "

0 commit comments

Comments
 (0)