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

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - 加菲猫

网宿科技股份有限公司投资者关系活动记录表(2014.3.30) 网宿科技投资者关系活动记录2016年10月31日 [转载]20131206 网宿科技电话交流会纪要 114 的 dns 的解析测试 分析ext2文件系统磁盘分区结构 Scaling Redis [ZT] Linuxfs Readinglist wma/mp3等格式转换为apple有声电子书格式(m4b) 以及itunes导入码率设置 Progressive-download 对于文件格式的要求 CDN Origin Pull 牛项目 Harvest CDN设计:[笔记]Analysis of Enterprise Media Server Workloads CDN设计 - 层级化的cache_A Apple http live streaming 不支持windows? 关于pdf转doc (word) 的工具 - Solid Converter PDF Berkeley DB Hash、Btree、Queue、Recno 选择 一些校园招聘的题目和分析 6"电纸书/电子书 - PaperCrop pdf重排使用心得 A CAP Solution (Proving Brewer Wrong)
strlcpy和strlcat
加菲猫 · 2015-04-26 · via 博客园 - 加菲猫

strncpy 等主要的问题还是虽然不会溢出,但是满了就不给缓冲区添加0结束符了,以前在项目里面自己还写了个 safe_strcpy 现在发现早就有了

http://blog.csdn.net/linyt/article/details/4383328

找了一下,代码可以在 libbsd 里面有

size_t

strlcat(char *dst, const char *src, size_t siz)

{

        char *d = dst;

        const char *s = src;

        size_t n = siz;

        size_t dlen;

        while (n-- != 0 && *d != '\0')

                d++;

        dlen = d - dst;

        n = siz - dlen;

        if (n == 0)

                return(dlen + strlen(s));

        while (*s != '\0') {

                if (n != 1) {

                        *d++ = *s;

                        n--;

                }

                s++;

        }

        *d = '\0';

        return(dlen + (s - src));       

}

size_t

strlcpy(char *dst, const char *src, size_t siz)

{

        char *d = dst;

        const char *s = src;

        size_t n = siz;

        if (n != 0) {

                while (--n != 0) {

                        if ((*d++ = *s++) == '\0')

                                break;

                }

        }

        if (n == 0) {

                if (siz != 0)

                        *d = '\0';              

                while (*s++)

                        ;

        }

        return(s - src - 1);    

}