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

Fix string truncation warnings related to PATH_MAX #1244

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

hramrach
Copy link
Contributor

@hramrach hramrach commented Jan 6, 2024

There are a number of places where rrdtool combines multiple PATH_MAX sized strings into one.

PATH_MAX is a constant that tends to work in practice a lot of the time but may not reflect the real capabilities of the system in real time.

In place of on-stack buffers of PATH_MAX size allocate memory dynamically. Initialize the pointers to NULL so they can be all freed unconditionally on exit.

Fixes: #1223

Note: this is not tested, and the changes are substantial. If this looks like a generally good way to do it it warrants running the code with valgrind or similar.

Also it is not clear that asprintf implementation is needed. configure tests for asprintf presence but a windows implementation is provided.

Copy link

codecov bot commented Jan 6, 2024

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (6892508) 51.02% compared to head (4449577) 51.11%.

Files Patch % Lines
src/rrd_daemon.c 75.80% 15 Missing ⚠️
src/rrd_list.c 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1244      +/-   ##
==========================================
+ Coverage   51.02%   51.11%   +0.09%     
==========================================
  Files          45       45              
  Lines       18214    18251      +37     
==========================================
+ Hits         9293     9329      +36     
- Misses       8921     8922       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@c72578
Copy link
Collaborator

c72578 commented Jan 6, 2024

Also it is not clear that asprintf implementation is needed. configure tests for asprintf presence but a windows implementation is provided.

Concerning Windows, MSYS2 MinGW-w64 provides asprintf:
checking for asprintf... yes

And for the MSVC builds (librrd-8.vcxproj) there are:
win32/asprintf.c
win32/asprintf.h

@oetiker
Copy link
Owner

oetiker commented Jan 7, 2024

the build-test-linux does run valgrind ... not sure if the tests are hitting path areas ... maybe have a look?

this is how to run the tests on the commandline

        make check TESTS_STYLE="valgrind-logfile" TESTS="modify1 modify2 modify3 modify4 modify5 tune1 tune2 graph1 rrdcreate dump-restore create-with-source-1 create-with-source-2 create-with-source-3 create-with-source-4 create-with-source-and-mapping-1 create-from-template-1 dcounter1 vformatter1 list1 pdp-calc1"

@hramrach
Copy link
Contributor Author

hramrach commented Jan 7, 2024

And there is whole printf implementation so there should not be a problem with any platform lacking asprinf.

Yes, I see that the tests run valgrind, and the coverage tool points out that some of the error cases are not tested.

@hramrach hramrach marked this pull request as ready for review January 7, 2024 11:46
Copy link
Owner

@oetiker oetiker left a comment

Choose a reason for hiding this comment

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

please add to the CHANGES file!

There are a number of places where rrdtool combines multiple PATH_MAX
sized strings into one.

PATH_MAX is a constant that tends to work in practice a lot of the time
but may not reflect the real capabilities of the system in real time.

In place of on-stack buffers of PATH_MAX size allocate memory
dynamically. Initialize the pointers to NULL so they can be all freed
unconditionally on exit.

Fixes: oetiker#1223
Signed-off-by: Michal Suchanek <[email protected]>
@oetiker oetiker merged commit e66ec71 into oetiker:master Jan 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Several compiler warnings during build (make check)
3 participants