xbps_get_pkgidx_string(): don't forget nul.
--HG-- extra : convert_revision : 60f0e28fceb4b9e789612bd2f6183f85b63bd44b
This commit is contained in:
parent
3f7c353356
commit
4fd0807c5f
1 changed files with 7 additions and 5 deletions
12
lib/plist.c
12
lib/plist.c
|
@ -158,24 +158,26 @@ xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
|||
char *
|
||||
xbps_get_pkgidx_string(const char *repofile)
|
||||
{
|
||||
char plist[PATH_MAX], *len, *result;
|
||||
char plist[PATH_MAX], *dest, *result;
|
||||
size_t len = 0;
|
||||
|
||||
assert(repofile != NULL);
|
||||
|
||||
/* Add full path to pkg-index.plist file */
|
||||
len = strncpy(plist, repofile, sizeof(plist) - 1);
|
||||
if (sizeof(*len) >= sizeof(plist))
|
||||
dest = strncpy(plist, repofile, sizeof(plist) - 1);
|
||||
if (sizeof(*dest) >= sizeof(plist))
|
||||
return NULL;
|
||||
|
||||
plist[sizeof(plist) - 1] = '\0';
|
||||
strncat(plist, "/", sizeof(plist) - strlen(plist) - 1);
|
||||
strncat(plist, XBPS_PKGINDEX, sizeof(plist) - strlen(plist) - 1);
|
||||
|
||||
result = malloc(strlen(plist));
|
||||
len = strlen(plist);
|
||||
result = malloc(len + 1);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
strncpy(result, plist, strlen(plist));
|
||||
strncpy(result, plist, len);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue