|
Boost Users : |
From: McGrath, Justin M (jmcgrath_at_[hidden])
Date: 2023-11-16 15:43:09
Thanks Matt.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net
________________________________________
From: Matt Borland <matt_at_[hidden]>
Sent: Thursday, November 16, 2023 9:32 AM
To: McGrath, Justin M
Cc: Boost users list; mario.mulansky_at_[hidden]
Subject: Re: [Boost-users] Could sprintf be replaced with snprintf?
On Nov 16, 2023, at 4:22â¯PM, McGrath, Justin M <jmcgrath_at_[hidden]> wrote:
Hi Matt,
In ODEINT it's called in max_step_checker.hpp.
```
const int m_max_steps;
...
char error_msg[200];
std::sprintf(error_msg, "Max number of iterations exceeded (%d).", m_max_steps);
...
char error_msg[200];
std::sprintf(error_msg, "Max number of iterations exceeded (%d).", m_max_steps);
```
It looks to me that neither of these uses could possibly overflow, but for whatever reason people have latched onto the idea that sprintf should never be used.
Cheers,
Justin
Justin,
It looks like someone filed a PR about a year ago to fix that: https://github.com/boostorg/odeint/pull/58
Matt