From 8973875a1fc52ec35c255afd34c9cd7d5c285caa Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 28 Aug 2011 23:05:20 -0500 Subject: _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 - ), 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 --- lib/libalpm/deps.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/deps.c') diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 47b7637a..e268157a 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -441,7 +441,11 @@ alpm_depend_t *_alpm_splitdep(const char *depstring) } /* copy the right parts to the right places */ - STRNDUP(depend->name, depstring, ptr - depstring, return NULL); + if(ptr) { + STRNDUP(depend->name, depstring, ptr - depstring, return NULL); + } else { + STRDUP(depend->name, depstring, return NULL); + } depend->name_hash = _alpm_hash_sdbm(depend->name); if(version) { STRDUP(depend->version, version, return NULL); -- cgit v1.2.3-24-g4f1b