Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_util: fix leading zeros in time_key #8116

Closed
wants to merge 2 commits into from

Conversation

PettitWesley
Copy link
Contributor

Fixes #7538


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@PettitWesley PettitWesley temporarily deployed to pr October 31, 2023 22:38 — with GitHub Actions Inactive
@PettitWesley PettitWesley temporarily deployed to pr October 31, 2023 22:38 — with GitHub Actions Inactive
@PettitWesley PettitWesley temporarily deployed to pr October 31, 2023 22:38 — with GitHub Actions Inactive
@PettitWesley PettitWesley temporarily deployed to pr October 31, 2023 23:03 — with GitHub Actions Inactive
Copy link
Collaborator

@nokute78 nokute78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using printf format like "%09" PRIu64 ?

"%" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000);
snprintf(nanosecond_str, FLB_AWS_NANOSECOND_FORMATTER_LENGTH+1,
snprintf(nanosecond_str, FLB_AWS_NANOSECOND_LENGTH+1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ensuring like following code ?

snprintf(nanosecond_str, FLB_AWS_NANOSECOND_LENGTH+1, "%09" PRIu64, (uint64_t) tms->tm.tv_nsec);

Example code:

#include <stdio.h>
#include <inttypes.h>

int main()
{
  uint64_t val = 1;
  int i;

  for (i=0; i<9; i++)  {
    printf("i=%d " "%09" PRIu64 "\n", i, val);
    val *= 10;
  }
}

Output is

i=0 000000001
i=1 000000010
i=2 000000100
i=3 000001000
i=4 000010000
i=5 000100000
i=6 001000000
i=7 010000000
i=8 100000000

@@ -1002,28 +1017,34 @@ size_t flb_aws_strftime_precision(char **out_buf, const char *time_format,
}

/* Replace %3N to millisecond, %9N and %L to nanosecond in time_format. */
snprintf(millisecond_str, FLB_AWS_MILLISECOND_FORMATTER_LENGTH+1,
snprintf(millisecond_str, FLB_AWS_MILLISECOND_LENGTH+1,
Copy link
Collaborator

@nokute78 nokute78 Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ensuring like following code ?

snprintf(nanosecond_str, FLB_AWS_MILLISECOND_LENGTH+1, "%03" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000);

@edsiper
Copy link
Member

edsiper commented Nov 7, 2023

image

Copy link
Contributor

github-actions bot commented Feb 7, 2024

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Feb 7, 2024
@lecaros
Copy link
Contributor

lecaros commented Feb 22, 2024

ping @PettitWesley

@github-actions github-actions bot removed the Stale label Feb 23, 2024
Copy link
Contributor

github-actions bot commented Jun 8, 2024

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@edsiper
Copy link
Member

edsiper commented Aug 7, 2024

fixed in #9128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kinesis_streams plugin truncates time_key when using millsecond precision format
4 participants