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

scan-build complaint on cookie_interface.c #7497

Closed
bagder opened this issue Jul 26, 2021 · 4 comments
Closed

scan-build complaint on cookie_interface.c #7497

bagder opened this issue Jul 26, 2021 · 4 comments

Comments

@bagder
Copy link
Member

@bagder bagder commented Jul 26, 2021

Unfortunately, #7490 caused scan-build to yell:

cookie_interface.c: In function ‘main’:
cookie_interface.c:96:53: error: ‘%.0lf’ directive output may be truncated writing between 1 and 310 bytes into a region of size 230 [-Werror=format-truncation=]
     snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0lf\t%s\t%s",
                                                     ^~~~~
cookie_interface.c:96:5: note: ‘snprintf’ output between 70 and 379 bytes into a destination of size 256
     snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0lf\t%s\t%s",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              ".example.com", "TRUE", "/", "FALSE",
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              difftime(time(NULL) + 31337, (time_t)0),
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              "PREF", "hello example, i like you very much!");
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

_Originally posted by @bagder in https://github.com/curl/curl/pull/7490#issuecomment-886606852_
@danielgustafsson
Copy link
Member

@danielgustafsson danielgustafsson commented Jul 26, 2021

Isn't %lf a C99 construct with undefined behavior in C89?

@bagder
Copy link
Member Author

@bagder bagder commented Jul 26, 2021

I suppose the l (ell) should be removed from there, right?

@danielgustafsson
Copy link
Member

@danielgustafsson danielgustafsson commented Jul 26, 2021

bagder added a commit that referenced this issue Jul 26, 2021
Follow-up to 4b79c4f

Fixes #7497
@bagder
Copy link
Member Author

@bagder bagder commented Jul 26, 2021

I think we should, if nothing else to make it easier for us to run the checkers and tools with the same conditions.

@bagder bagder closed this in 17c7a56 Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants