mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix strerror_r(3) range error case.
This commit is contained in:
parent
0b1af77ca0
commit
0b085cbcf1
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
|
@ -30,7 +30,8 @@ extern "C" int strerror_r(int errnum, char* dest, size_t dest_len)
|
|||
const char* msg = sortix_strerror(errnum);
|
||||
if ( !msg )
|
||||
return -1;
|
||||
if ( strlcpy(dest, msg, dest_len) != strlen(msg) )
|
||||
errno = ERANGE;
|
||||
if ( dest_len < strlen(msg) + 1 )
|
||||
return errno = ERANGE;
|
||||
strcpy(dest, msg);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue