Research Article

Copying and Concatenating C Strings with the str5 Functions

by  Eric Sanchis
journal cover
International Journal of Computer Applications
Foundation of Computer Science (FCS), NY, USA
Volume 117 - Issue 24
Published: May 2015
Authors: Eric Sanchis
10.5120/20702-3380
PDF

Eric Sanchis . Copying and Concatenating C Strings with the str5 Functions. International Journal of Computer Applications. 117, 24 (May 2015), 14-18. DOI=10.5120/20702-3380

                        @article{ 10.5120/20702-3380,
                        author  = { Eric Sanchis },
                        title   = { Copying and Concatenating C Strings with the str5 Functions },
                        journal = { International Journal of Computer Applications },
                        year    = { 2015 },
                        volume  = { 117 },
                        number  = { 24 },
                        pages   = { 14-18 },
                        doi     = { 10.5120/20702-3380 },
                        publisher = { Foundation of Computer Science (FCS), NY, USA }
                        }
                        %0 Journal Article
                        %D 2015
                        %A Eric Sanchis
                        %T Copying and Concatenating C Strings with the str5 Functions%T 
                        %J International Journal of Computer Applications
                        %V 117
                        %N 24
                        %P 14-18
                        %R 10.5120/20702-3380
                        %I Foundation of Computer Science (FCS), NY, USA
Abstract

The copy and the concatenation of strings constitute a recurring subject of polemics within the C programmers community. They generally relate to the respective advantages and disadvantages of the three principal couples of functions which are strcpy()/strcat(), strncpy()/strncat() and strlcpy()/strlcat(). This article describes two new functions str5cpy() and str5cat() which were designed to replace those functions while bringing clearness, coherence, safety and facility of use which the preceding functions lack more or less. The central point of the str5cpy() and str5cat() functions is their articulation around 5 parameters (and not 2 or 3) which will enable them to deal with the various checks, sources of many errors when they are not or badly done by the programmer, and which provide a truly significant return value indicating the action actually carried out.

References
  • Todd C. Miller, Theo de Raadt, strlcpy and strlcat – Consistent, Safe String Copy and Concatenation, USENIX 1999 https://www. usenix. org/legacy/events/usenix99/full_papers/millert/millert. pdf
  • libc-alpha archive, August 2000, PATCH: safe string copy and concetation, https://www. sourceware. org/ml/libc-alpha/2000-08/threads. html
  • libc-alpha archive, September 2014, [PATCH] Implement strlcpy [BZ #178] https://sourceware. org/ml/libc-alpha/2014-09/threads. html
  • Eric Sanchis, Copying and concatenating strings with the str5 functions, October 2014 http://aral. iut-rodez. fr/en/sanchis/miscellaneous/str5/str5_v09. 1. pdf
Index Terms
Computer Science
Information Sciences
No index terms available.
Keywords

C strings str5cpy str5cat strncpy strncat strlcpy strlcat buffer overflow.

Powered by PhDFocusTM