惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 多米诺

IIS W3SVC 无法启动1068错误的解决 Windows 10 自动升级画面 国内网站常用的一些 CDN 公共库加速服务 WebBrowser与IE的关系,如何设置WebBrowser工作在IE9、10、11模式下? [转]Windows 8.1删除这台电脑中视频/文档/下载等六个文件夹的方法 VS2013无法链接到TFS(Visual studio online),错误TF31001,TF31002 WP8 对音视频格式支持的完整说明 硬盘崩溃之后 MSDN Windows 下载 12 Source Code Profilers for C & C++ [转].NET Logging Tools and Libraries Qt 4.7 在VS2010环境下的编译 HttpWebRequest的使用方法 [原创]采用SocketAsyncEventArgs实现异步UDP收发 [转]合约程序员——中小型企业信息化的最佳选择 [转]高可用高性能计算机系统配置与调谐的基本策略 2008在网络的边缘到达了 .Net framework 3.5 无法安装,附解决方法 查找重复的美女图片 :-)
sprintf_s的教训
多米诺 · 2013-08-28 · via 博客园 - 多米诺

    sprintf_s 是个比sprintf更安全的函数,今天在使用的过程中犯了个错误,代码的大致意思如下

 1 void Test_sprintf_s()
 2 {
 3     char    buff[64];
 4 
 5     memset(buff, 0, sizeof(buff));
 6 
 7     sprintf_s(buff, sizeof(buff), "AAAAAA-");
 8 
 9     sprintf_s(buff+strlen(buff), sizeof(buff), "BBBBBBB-");
10 
11 }

  上面的第9行犯了个错误,相信你也能看出来。

  奇怪的是在Release版本下没有问题,Debug下才会导致崩溃,并出现下述提示:

  研究下来,发现sprintf_s执行后,会把整个缓冲区的尾部填满 0xFE。如下图:

毫无疑问,执行到代码第9行,buff后的内存也被错误的填写了0xfe,不出错才怪。