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

zpool_influxdb: fix -Werror=stringop-truncation #12344

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

gmelikov
Copy link
Member

@gmelikov gmelikov commented Jul 9, 2021

Signed-off-by: George Melikov mail@gmelikov.ru

Cherry-picked from #12222 as separate granular change.

Motivation and Context

During ASAN tests I've found a warning (treated as error) https://github.com/gmelikov/zfs/runs/2795980815?check_suite_focus=true

In function 'strncpy',
    inlined from 'print_recursive_stats' at zpool_influxdb.c:687:10:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]

How Has This Been Tested?

Just builds via CI and no ASAN warnings about it.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@gmelikov gmelikov linked an issue Jul 9, 2021 that may be closed by this pull request
@ghost
Copy link

ghost commented Jul 9, 2021

Could we use strlcpy instead?

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jul 13, 2021
@behlendorf
Copy link
Contributor

behlendorf commented Jul 13, 2021

Yes, I agree let's use strlcpy() here if possible since for the most part we've avoided using strncpy() when possible.

Use strlcpy instead of problematic strncpy

Signed-off-by: George Melikov <mail@gmelikov.ru>
@gmelikov
Copy link
Member Author

@freqlabs @behlendorf sorry for delay, agree, done.

@tonynguien tonynguien added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jul 15, 2021
@tonynguien tonynguien merged commit b17b199 into openzfs:master Jul 16, 2021
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Aug 23, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes openzfs#12344
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Aug 24, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes openzfs#12344
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Aug 24, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes openzfs#12344
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Aug 24, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes openzfs#12344
behlendorf pushed a commit that referenced this pull request Aug 31, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes #12344
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 15, 2021
Use strlcpy instead of problematic strncpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes openzfs#12344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run CI tests with AddressSanitizer
4 participants