1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-10 05:18:16 -05:00

_alpm_splitdep(): don't pass bogus length value to strndup

If we fell through to the ALPM_DEP_MOD_ANY case, ptr would be NULL, and
we would pass (0 - <str>), which is a rather large negative number or
bogus positive number, depending on signed/unsigned. Just use strdup in
the case where we don't have a ptr available.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-08-28 23:05:20 -05:00
parent b221af660d
commit 8973875a1f

View File

@ -441,7 +441,11 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
} }
/* copy the right parts to the right places */ /* copy the right parts to the right places */
if(ptr) {
STRNDUP(depend->name, depstring, ptr - depstring, return NULL); STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
} else {
STRDUP(depend->name, depstring, return NULL);
}
depend->name_hash = _alpm_hash_sdbm(depend->name); depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) { if(version) {
STRDUP(depend->version, version, return NULL); STRDUP(depend->version, version, return NULL);