libpayload: Add the null terminator to the end of the duplicated string

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Myles Watson <mylesgw@gmail.com>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3268 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Jordan Crouse 2008-04-25 23:07:39 +00:00
parent 20ce60c9aa
commit c781584936
1 changed files with 2 additions and 1 deletions

View File

@ -173,11 +173,12 @@ char *strchr(const char *s, int c)
char *strdup(const char *s)
{
int n = strlen(s);
char *p = malloc(n);
char *p = malloc(n + 1);
if (p != NULL)
strncpy(p, s, n);
p[n] = 0;
return p;
}