From f8f2aa378121f71cc9b5042b8552a5a3abe6449b Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 14 Nov 2021 20:07:11 -0800 Subject: [PATCH] IMPORT: Fix importing to element without permission. --- src/commands.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/commands.c b/src/commands.c index da8a8f5b..4893d80a 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3354,7 +3354,7 @@ do_import (struct client_s *client, const char *root_element, root = xmlDocGetRootElement (doc); root = root->children; - if (root->type != XML_ELEMENT_NODE) + if (!root || root->type != XML_ELEMENT_NODE) { rc = GPG_ERR_BAD_DATA; goto fail; @@ -3386,7 +3386,10 @@ do_import (struct client_s *client, const char *root_element, if (!name) rc = GPG_ERR_BAD_DATA; - else if (!req) + else + rc = xml_is_element_owner (client, n, 0); + + if (!rc && !req) { /* No --root argument passed. Overwrite the current documents' root * element matching the root element of the imported data. */ @@ -3404,8 +3407,13 @@ do_import (struct client_s *client, const char *root_element, goto fail; if (!rc) - (void)xml_unlink_node (client, tmp); + { + rc = xml_is_element_owner (client, tmp, 0); + if (rc) + goto fail; + } + (void)xml_unlink_node (client, tmp); rc = 0; } } -- 2.11.4.GIT