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 to compile with -Werror=format-security #80

Closed
svigerske opened this issue Mar 2, 2019 · 1 comment
Closed

fix to compile with -Werror=format-security #80

svigerske opened this issue Mar 2, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@svigerske
Copy link
Member

Issue created by migration from Trac.

Original creator: @mlubin

Original creation time: 2013-08-06 03:44:57

Version:

I'm working on updating the Debian package for coinutils, and they now strongly encourage compiling with -Werror=format-security. This short patch is required to make this work.

--- a/CoinUtils/src/CoinMessageHandler.cpp
+++ b/CoinUtils/src/CoinMessageHandler.cpp
`@``@` -820,7 +820,7 `@``@`
          sprintf(messageOut_,g_format_,doublevalue);
          if (next != format_+2) {
            messageOut_+=strlen(messageOut_);
-           sprintf(messageOut_,format_+2);
+           strcpy(messageOut_,format_+2);
          }
        }
        messageOut_+=strlen(messageOut_);
@svigerske svigerske added bug Something isn't working minor labels Mar 2, 2019
@svigerske
Copy link
Member Author

Current code says

          if (next != format_ + 2) {
            messageOut_ += strlen(messageOut_);
            sprintf(messageOut_, "%s", format_ + 2);
          }

This should also have suppressed this warning/error. But I agree that using strcpy would be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant