-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eliminated the need for strlcat in the library
- Loading branch information
Showing
3 changed files
with
1 addition
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,48 +347,6 @@ rc_getctime(void) | |
return timev.tv_sec + ((double)timev.tv_usec) / 1000000.0; | ||
} | ||
|
||
#ifndef HAVE_STRLCAT | ||
/* | ||
* Replacement for a missing strlcat. | ||
* | ||
* Provides the same functionality as the *BSD function strlcat, originally | ||
* developed by Todd Miller and Theo de Raadt. strlcat works similarly to | ||
* strncat, except simpler. The result is always nul-terminated even if the | ||
* source string is longer than the space remaining in the destination string, | ||
* and the total space required is returned. The third argument is the total | ||
* space available in the destination buffer, not just the amount of space | ||
* remaining. | ||
* | ||
* The canonical version of this file is maintained in the rra-c-util package, | ||
* which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. | ||
* | ||
* Written by Russ Allbery <[email protected]> | ||
* | ||
* The authors hereby relinquish any claim to any copyright that they may have | ||
* in this work, whether granted under contract or by operation of law or | ||
* international treaty, and hereby commit to the public, at large, that they | ||
* shall not, at any time in the future, seek to enforce any copyright in this | ||
* work against any person or entity, or prevent any person or entity from | ||
* copying, publishing, distributing or creating derivative works of this | ||
* work. | ||
*/ | ||
|
||
size_t | ||
rc_strlcat(char *dst, const char *src, size_t size) | ||
{ | ||
size_t used, length, copy; | ||
|
||
used = strlen(dst); | ||
length = strlen(src); | ||
if (size > 0 && used < size - 1) { | ||
copy = (length >= size - used) ? size - used - 1 : length; | ||
memcpy(dst + used, src, copy); | ||
dst[used + copy] = '\0'; | ||
} | ||
return used + length; | ||
} | ||
#endif | ||
|
||
/* | ||
* Copyright (c) 1998 Todd C. Miller <[email protected]> | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters