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

format_to_n unsafe when arguments exceeds some size #2029

Closed
arthurfait opened this issue Nov 18, 2020 · 1 comment
Closed

format_to_n unsafe when arguments exceeds some size #2029

arthurfait opened this issue Nov 18, 2020 · 1 comment

Comments

@arthurfait
Copy link

format_to_n unsafe when arguments exceeds some size (256?)

Relates to closed #2028 (#1996)

Following peace of code

#include <fmt/format.h>
int main()
{
    char buff[80];
    const char *a = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
    fmt::format_to_n(std::begin(buff), 79,FMT_STRING("{} "), a);
    fmt::print("done");
    return 0;
}

build with following rule:
-fstack-protector-strong

gives

*** stack smashing detected ***: terminated
@vitaut
Copy link
Contributor

vitaut commented Nov 18, 2020

Great catch, thanks! Fixed in 2c734c9.

@vitaut vitaut closed this as completed Nov 18, 2020
vitaut added a commit that referenced this issue Nov 24, 2020
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

No branches or pull requests

2 participants