CRT 9.0 vsprintf_s 对长格式字符串的参数验证

发布于 2024-10-08 08:22:39 字数 301 浏览 0 评论 0原文

来自此处

这些函数的版本 _s 和 _p 后缀是更安全的版本。这些版本验证了 格式化字符串并会生成 如果格式字符串不是,则异常 格式良好(例如,如果无效 使用格式化字符)。

我刚刚发现如果格式字符串大于输出缓冲区大小,则认为格式字符串格式不正确。有谁知道确认所有 *_s 打印功能的文档?

谢谢

From here:

The versions of these functions with
_s and _p suffixes are the more secure versions. These versions validate the
format strings and will generate an
exception if the format string is not
well formed (for example, if invalid
formatting characters are used).

I just discovered the format string is considered not well formed if it is larger than the output buffer size. Does anyone know of documentation that confirms this for all *_s print functions?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杯敬自由 2024-10-15 08:22:39

看起来默认行为是在超过输出缓冲区大小时抛出 CRT 错误,无论源如何。我预计如果超出输出缓冲区大小,输出将被静默截断。因此,如果格式字符串已经太长,则尝试填充它是没有意义的。

Looks like the default behavior is to throw the CRT error if output buffer size is exceeded, regardless of source. I expected the output to be silently truncated if the output buffer size is exceeded. Thus, there is no point in attempting to fill in the format string if it is too long already.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文