Quickfix for libpayload's strcpy() to properly NUL-terminate strings (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3184 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
316e07fb04
commit
29014056e7
@ -130,8 +130,7 @@ int strncmp(const char *s1, const char *s2, int maxlen)
|
|||||||
|
|
||||||
char *strncpy(char *d, const char *s, int n)
|
char *strncpy(char *d, const char *s, int n)
|
||||||
{
|
{
|
||||||
/* use +1 to get the null terminator */
|
/* Use +1 to get the NUL terminator. */
|
||||||
|
|
||||||
int max = n > strlen(s) + 1 ? strlen(s) + 1 : n;
|
int max = n > strlen(s) + 1 ? strlen(s) + 1 : n;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -143,7 +142,7 @@ char *strncpy(char *d, const char *s, int n)
|
|||||||
|
|
||||||
char *strcpy(char *d, const char *s)
|
char *strcpy(char *d, const char *s)
|
||||||
{
|
{
|
||||||
return strncpy(d, s, strlen(s));
|
return strncpy(d, s, strlen(s) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strncat(char *d, const char *s, int n)
|
char *strncat(char *d, const char *s, int n)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user