xbps_get_pkgidx_string(): don't forget nul.

--HG--
extra : convert_revision : 60f0e28fceb4b9e789612bd2f6183f85b63bd44b
This commit is contained in:
Juan RP 2008-12-22 05:09:24 +01:00
parent 3f7c353356
commit 4fd0807c5f

View file

@ -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;
}