Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Test all return of ucl_object_key
Baptiste Daroussin committed 12 years ago
commit 3172ea6414aca53ce010fca1461455425b99155e
parent 533e255
3 files changed +57 -14
modified libpkg/pkg_config.c
@@ -365,12 +365,16 @@ obj_walk_object(ucl_object_t *obj, struct pkg_config *conf)
	struct pkg_config_kv *kv;
	ucl_object_t *cur;
	ucl_object_iter_t it = NULL;
+
	const char *key;

	while ((cur = ucl_iterate_object(obj, &it, true))) {
		if (cur->type != UCL_STRING)
			continue;
		kv = malloc(sizeof(struct pkg_config_kv));
-
		kv->key = strdup(ucl_object_key(cur));
+
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
+
		kv->key = strdup(key);
		kv->value = strdup(ucl_object_tostring(cur));
		HASH_ADD_STR(conf->kvlist, value, kv);
	}
@@ -389,6 +393,8 @@ pkg_object_walk(ucl_object_t *obj, struct pkg_config *conf_by_key)
	while ((cur = ucl_iterate_object(obj, &it, true))) {
		sbuf_clear(b);
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		for (i = 0; i < strlen(key); i++)
			sbuf_putc(b, toupper(key[i]));
		sbuf_finish(b);
@@ -812,6 +818,8 @@ walk_repo_obj(ucl_object_t *obj)

	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		r = pkg_repo_find_ident(key);
		if (r != NULL)
			pkg_debug(1, "PkgConfig: overwriting repository %s", key);
@@ -1105,6 +1113,8 @@ pkg_init(const char *path, const char *reposdir)
		if (obj->type == UCL_OBJECT) {
			while ((cur = ucl_iterate_object(obj, &it, true))) {
				key = ucl_object_key(cur);
+
				if (key == NULL)
+
					continue;
				if (strcasecmp(key, "REPOS_DIR") == 0 &&
				    cur->type != UCL_ARRAY)
					fallback = true;
modified libpkg/pkg_manifest.c
@@ -376,6 +376,8 @@ pkg_object(struct pkg *pkg, ucl_object_t *obj, int attr)
	pkg_debug(3, "%s", "Manifest: parsing object");
	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		switch (attr) {
		case PKG_DEPS:
			if (cur->type != UCL_OBJECT && cur->type != UCL_ARRAY)
@@ -498,11 +500,16 @@ pkg_set_files_from_object(struct pkg *pkg, ucl_object_t *obj)
	void *set = NULL;
	mode_t perm = 0;
	struct sbuf *fname = NULL;
-
	const char *key;
+
	const char *key, *okey;

-
	urldecode(ucl_object_key(obj), &fname);
+
	okey = ucl_object_key(obj);
+
	if (okey == NULL)
+
		return (EPKG_FATAL);
+
	urldecode(okey, &fname);
	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		if (!strcasecmp(key, "uname") && cur->type == UCL_STRING)
			uname = ucl_object_tostring(cur);
		else if (!strcasecmp(key, "gname") && cur->type == UCL_STRING)
@@ -540,11 +547,16 @@ pkg_set_dirs_from_object(struct pkg *pkg, ucl_object_t *obj)
	mode_t perm = 0;
	bool try = false;
	struct sbuf *dirname = NULL;
-
	const char *key;
+
	const char *key, *okey;

-
	urldecode(ucl_object_key(obj), &dirname);
+
	okey = ucl_object_key(obj);
+
	if (okey == NULL)
+
		return (EPKG_FATAL);
+
	urldecode(okey, &dirname);
	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		if (!strcasecmp(key, "uname") && cur->type == UCL_STRING)
			uname = ucl_object_tostring(cur);
		else if (!strcasecmp(key, "gname") && cur->type == UCL_STRING)
@@ -577,15 +589,20 @@ pkg_set_deps_from_object(struct pkg *pkg, ucl_object_t *obj)
	ucl_object_iter_t it = NULL, it2;
	const char *origin = NULL;
	const char *version = NULL;
-
	const char *key;
+
	const char *key, *okey;
	int64_t vint = 0;
	char vinteger[BUFSIZ];

-
	pkg_debug(2, "Found %s", ucl_object_key(obj));
+
	okey = ucl_object_key(obj);
+
	if (okey == NULL)
+
		return (EPKG_FATAL);
+
	pkg_debug(2, "Found %s", okey);
	while ((self = ucl_iterate_object(obj, &it, (obj->type == UCL_ARRAY)))) {
		it2 = NULL;
		while ((cur = ucl_iterate_object(self, &it2, true))) {
			key = ucl_object_key(cur);
+
			if (key == NULL)
+
				continue;
			if (cur->type != UCL_STRING) {
				/* accept version to be an integer */
				if (cur->type == UCL_INT && strcasecmp(key, "version") == 0) {
@@ -595,7 +612,7 @@ pkg_set_deps_from_object(struct pkg *pkg, ucl_object_t *obj)
				}

				pkg_emit_error("Skipping malformed dependency entry "
-
						"for %s", ucl_object_key(obj));
+
						"for %s", okey);
				continue;
			}
			if (strcasecmp(key, "origin") == 0)
@@ -604,9 +621,9 @@ pkg_set_deps_from_object(struct pkg *pkg, ucl_object_t *obj)
				version = ucl_object_tostring(cur);
		}
		if (origin != NULL && (version != NULL || vint > 0))
-
			pkg_adddep(pkg, ucl_object_key(obj), origin, vint > 0 ? vinteger : version, false);
+
			pkg_adddep(pkg, okey, origin, vint > 0 ? vinteger : version, false);
		else
-
			pkg_emit_error("Skipping malformed dependency %s", ucl_object_key(obj));
+
			pkg_emit_error("Skipping malformed dependency %s", okey);
	}

	return (EPKG_OK);
@@ -619,10 +636,14 @@ parse_manifest(struct pkg *pkg, struct pkg_manifest_key *keys, ucl_object_t *obj
	ucl_object_iter_t it = NULL;
	struct pkg_manifest_key *selected_key;
	struct dataparser *dp;
+
	const char *key;

	while ((cur = ucl_iterate_object(obj, &it, true))) {
-
		pkg_debug(2, "Manifest: found key: '%s'", ucl_object_key(cur));
-
		HASH_FIND_STR(keys, ucl_object_key(cur), selected_key);
+
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
+
		pkg_debug(2, "Manifest: found key: '%s'", key);
+
		HASH_FIND_STR(keys, key, selected_key);
		if (selected_key != NULL) {
			HASH_FIND_UCLT(selected_key->parser, &cur->type, dp);
			if (dp != NULL) {
@@ -645,6 +666,7 @@ pkg_parse_manifest(struct pkg *pkg, char *buf, size_t len, struct pkg_manifest_k
	struct pkg_manifest_key *sk;
	struct dataparser *dp;
	bool fallback = false;
+
	const char *key;

	assert(pkg != NULL);
	assert(buf != NULL);
@@ -659,7 +681,10 @@ pkg_parse_manifest(struct pkg *pkg, char *buf, size_t len, struct pkg_manifest_k
		obj = ucl_parser_get_object(p);
		if (obj != NULL) {
			while ((cur = ucl_iterate_object(obj, &it, true))) {
-
				HASH_FIND_STR(keys, ucl_object_key(cur), sk);
+
				key = ucl_object_key(cur);
+
				if (key == NULL)
+
					continue;
+
				HASH_FIND_STR(keys, key, sk);
				if (sk != NULL) {
					HASH_FIND_UCLT(sk->parser, &cur->type, dp);
					if (dp == NULL) {
@@ -703,6 +728,7 @@ pkg_parse_manifest_file(struct pkg *pkg, const char *file, struct pkg_manifest_k
	bool fallback = false;
	struct pkg_manifest_key *sk;
	struct dataparser *dp;
+
	const char *key;

	assert(pkg != NULL);
	assert(file != NULL);
@@ -723,7 +749,10 @@ pkg_parse_manifest_file(struct pkg *pkg, const char *file, struct pkg_manifest_k
		obj = ucl_parser_get_object(p);
		if (obj != NULL) {
			while ((cur = ucl_iterate_object(obj, &it, true))) {
-
				HASH_FIND_STR(keys, ucl_object_key(cur), sk);
+
				key = ucl_object_key(cur);
+
				if (key == NULL)
+
					continue;
+
				HASH_FIND_STR(keys, key, sk);
				if (sk != NULL) {
					HASH_FIND_UCLT(sk->parser, &cur->type, dp);
					if (dp == NULL) {
modified libpkg/pkg_ports.c
@@ -668,6 +668,8 @@ parse_attributes(ucl_object_t *o, struct file_attr **a) {

	while ((cur = ucl_iterate_object(o, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		if (!strcasecmp(key, "owner") && cur->type == UCL_STRING) {
			free((*a)->owner);
			(*a)->owner = strdup(ucl_object_tostring(cur));
@@ -704,6 +706,8 @@ parse_and_apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, str

	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
+
		if (key == NULL)
+
			continue;
		if (!strcasecmp(key, "actions") && cur->type == UCL_ARRAY) {
			actions = cur;
			continue;