CFP last date
20 January 2025
Reseach Article

Copying and Concatenating C Strings with the str5 Functions

by Eric Sanchis
International Journal of Computer Applications
Foundation of Computer Science (FCS), NY, USA
Volume 117 - Number 24
Year of Publication: 2015
Authors: Eric Sanchis
10.5120/20702-3380

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 },
issue_date = { May 2015 },
volume = { 117 },
number = { 24 },
month = { May },
year = { 2015 },
issn = { 0975-8887 },
pages = { 14-18 },
numpages = {9},
url = { https://ijcaonline.org/archives/volume117/number24/20702-3380/ },
doi = { 10.5120/20702-3380 },
publisher = {Foundation of Computer Science (FCS), NY, USA},
address = {New York, USA}
}
%0 Journal Article
%1 2024-02-06T23:00:17.017661+05:30
%A Eric Sanchis
%T Copying and Concatenating C Strings with the str5 Functions
%J International Journal of Computer Applications
%@ 0975-8887
%V 117
%N 24
%P 14-18
%D 2015
%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
  1. 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
  2. libc-alpha archive, August 2000, PATCH: safe string copy and concetation, https://www. sourceware. org/ml/libc-alpha/2000-08/threads. html
  3. libc-alpha archive, September 2014, [PATCH] Implement strlcpy [BZ #178] https://sourceware. org/ml/libc-alpha/2014-09/threads. html
  4. 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

Keywords

C strings str5cpy str5cat strncpy strncat strlcpy strlcat buffer overflow.