Path: csiph.com!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: nobody@example.org (Scott) Newsgroups: comp.lang.c Subject: Re: Safer and more convenient strcpy() Date: Wed, 17 Apr 2019 01:19:22 GMT Organization: XMission http://xmission.com/ Message-ID: <5cb67e2b.2538657329@core> References: <0c54f650-7ece-4120-9ca4-c59972d8971a@googlegroups.com> <5cb54ab1.2459943736@core> <38440a99-738b-4436-9c53-6b96716cdb87@googlegroups.com> Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="16282"; mail-complaints-to="abuse@xmission.com" X-Newsreader: Forte Free Agent 1.21/32.243 Xref: csiph.com comp.lang.c:143157 On Tue, 16 Apr 2019 05:35:07 -0700 (PDT), eric.sanchis@iut-rodez.fr wrote: >strlcat(dst,"hello",sizeof(dst)) ; /* truncation is supposed allowed */ >if ( (ret=3Dstrtcat(dst,sizeof(dst),"hello")) < 0 ) Well, your approach is flawed, for one. I'll assume that you didn't read the strlcat man page far enough to get to the part where strlcat returns a value that can be used to detect potential overflows. if (strlcat(dst,"hello",sizeof(dst)) >= sizeof(dst)) /* problem*/ ;