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

Buffer overflow #2515

Closed
5 tasks
Vijaymulamalla opened this issue Dec 9, 2020 · 3 comments
Closed
5 tasks

Buffer overflow #2515

Vijaymulamalla opened this issue Dec 9, 2020 · 3 comments

Comments

@Vijaymulamalla
Copy link

Veracode scan flagged copied code(line 10707) as potential bug

What is the issue you have?

Buffer overflow

10693 if (k == 1)
10694 {
10695 // dE+123
10696 // len <= 1 + 5
10697
10698 buf += 1;
10699 }
10700 else
10701 {
10702 // d.igitsE+123
10703 // len <= max_digits10 + 1 + 5
10704
10705 assert(k > 1);
10706
10707 std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1));
10708 buf[1] = '.';
10709 buf += 1 + k;
10710 }

In line 10707, buffer is moved from "buf+1" to "buf+2". If the buffer is
full, one character will be moved beyond the buffer causing overflow.

Please describe the steps to reproduce the issue.

Can you provide a small but working code example?

What is the expected behavior?

And what is the actual behavior instead?

Which compiler and operating system are you using?

  • Compiler: ___
  • Operating system: ___

Which version of the library did you use?

  • latest release version 3.9.1
  • other release - please state the version: ___
  • the develop branch

If you experience a compilation error: can you compile and run the unit tests?

  • yes
  • no - please copy/paste the error message below
@nlohmann
Copy link
Owner

?

@Vijaymulamalla
Copy link
Author

Vijaymulamalla commented Dec 12, 2020 via email

@nlohmann
Copy link
Owner

Thanks!

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

No branches or pull requests

2 participants