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
Labels

Comments

@bagder
Copy link
Member

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

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

@bagder
Copy link
Member Author

bagder commented Jul 26, 2021

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

@danielgustafsson
Copy link
Member

danielgustafsson commented Jul 26, 2021 via email

@bagder
Copy link
Member Author

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.

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

Successfully merging a pull request may close this issue.

2 participants