-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mock - update func signatures for latest glibc (#9117)
glibc 2.38 includes strlcpy and strlcat, attempt to detect them before use
- Loading branch information
Showing
8 changed files
with
129 additions
and
119 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
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
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
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 |
---|---|---|
@@ -1,84 +1,78 @@ | ||
// https://gist.github.com/Fonger/98cc95ac39fbe1a7e4d9 | ||
|
||
#ifndef HAVE_STRLCAT | ||
/* | ||
'_cups_strlcat()' - Safely concatenate two strings. | ||
*/ | ||
|
||
size_t /* O - Length of string */ | ||
strlcat(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
#include <cstddef> | ||
#include <cstdlib> | ||
#include <cstring> | ||
|
||
extern "C" | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size_t dstlen; /* Length of destination string */ | ||
#ifdef STRLCAT_MISSING | ||
// '_cups_strlcat()' - Safely concatenate two strings. | ||
|
||
/* | ||
Figure out how much room is left... | ||
*/ | ||
size_t /* O - Length of string */ | ||
strlcat(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size_t dstlen; /* Length of destination string */ | ||
|
||
dstlen = strlen(dst); | ||
size -= dstlen + 1; | ||
// Figure out how much room is left... | ||
|
||
if (!size) | ||
{ | ||
return (dstlen); /* No room, return immediately... */ | ||
} | ||
dstlen = strlen(dst); | ||
size -= dstlen + 1; | ||
|
||
/* | ||
Figure out how much room is needed... | ||
*/ | ||
if (!size) | ||
{ | ||
return (dstlen); /* No room, return immediately... */ | ||
} | ||
|
||
srclen = strlen(src); | ||
// Figure out how much room is needed... | ||
|
||
/* | ||
Copy the appropriate amount... | ||
*/ | ||
srclen = strlen(src); | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
// Copy the appropriate amount... | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
} | ||
|
||
memcpy(dst + dstlen, src, srclen); | ||
dst[dstlen + srclen] = '\0'; | ||
|
||
return (dstlen + srclen); | ||
} | ||
#endif /* STRLCAT_MISSING */ | ||
|
||
memcpy(dst + dstlen, src, srclen); | ||
dst[dstlen + srclen] = '\0'; | ||
#ifdef STRLCPY_MISSING | ||
// '_cups_strlcpy()' - Safely copy two strings. | ||
|
||
return (dstlen + srclen); | ||
} | ||
#endif /* !HAVE_STRLCAT */ | ||
size_t /* O - Length of string */ | ||
strlcpy(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
|
||
#ifndef HAVE_STRLCPY | ||
/* | ||
'_cups_strlcpy()' - Safely copy two strings. | ||
*/ | ||
// Figure out how much room is needed... | ||
|
||
size_t /* O - Length of string */ | ||
strlcpy(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size--; | ||
|
||
/* | ||
Figure out how much room is needed... | ||
*/ | ||
srclen = strlen(src); | ||
|
||
size--; | ||
// Copy the appropriate amount... | ||
|
||
srclen = strlen(src); | ||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
} | ||
|
||
/* | ||
Copy the appropriate amount... | ||
*/ | ||
memcpy(dst, src, srclen); | ||
dst[srclen] = '\0'; | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
return (srclen); | ||
} | ||
#endif /* STRLCPY_MISSING */ | ||
|
||
memcpy(dst, src, srclen); | ||
dst[srclen] = '\0'; | ||
|
||
return (srclen); | ||
} | ||
#endif /* !HAVE_STRLCPY */ | ||
} // extern "C" |
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