mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Use strnlen(3) in strndup(3).
This commit is contained in:
parent
5e60007904
commit
c9e0fa687c
1 changed files with 1 additions and 3 deletions
|
@ -27,9 +27,7 @@
|
||||||
|
|
||||||
extern "C" char* strndup(const char* input, size_t n)
|
extern "C" char* strndup(const char* input, size_t n)
|
||||||
{
|
{
|
||||||
size_t inputsize = strlen(input);
|
size_t inputsize = strnlen(input, n);
|
||||||
if ( n < inputsize )
|
|
||||||
inputsize = n;
|
|
||||||
char* result = (char*) malloc(inputsize + 1);
|
char* result = (char*) malloc(inputsize + 1);
|
||||||
if ( !result )
|
if ( !result )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue