[openwrt/openwrt] cli: fix editor remove call validation

LEDE Commits lede-commits at lists.infradead.org
Sat Jul 19 12:23:34 PDT 2025


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/bd073e5cd9d6ca570af81d443fd4d00a49cf27ae

commit bd073e5cd9d6ca570af81d443fd4d00a49cf27ae
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Sat Jul 19 21:22:09 2025 +0200

    cli: fix editor remove call validation
    
    Skip type validation, fix passing values to remove
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/utils/cli/files/usr/share/ucode/cli/object-editor.uc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc b/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc
index 1f36ee9d07..639313b72f 100644
--- a/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc
+++ b/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc
@@ -136,10 +136,18 @@ export function remove_call(ctx, argv, named)
 			continue;
 
 		for (let idx in val) {
+			let orig_idx = idx;
 			if (idx != "" + +idx) {
 				let cur_idx = index(data, idx);
 				if (cur_idx >= 0)
 					idx = cur_idx + 1;
+				else
+					idx = null;
+			} else if (+idx > length(data))
+				idx = null;
+			if (idx == null) {
+				ctx.invalid_argument('Invalid value: %s', orig_idx);
+				continue;
 			}
 			data[+idx - 1] = null;
 		}
@@ -148,6 +156,8 @@ export function remove_call(ctx, argv, named)
 		if (cur.attribute_allow_empty && !length(cur_obj[name]))
 			delete cur_obj[name];
 	}
+	if (length(ctx.result.errors) > 0)
+		return;
 	call_change_cb(ctx, this, argv, named);
 	return ctx.ok();
 };
@@ -249,6 +259,7 @@ function remove_params(orig_params)
 			type: "enum",
 			get_object: val.get_object,
 			attribute: val.attribute ?? name,
+			no_validate: true,
 			value: param_values,
 			force_helptext: true,
 		};




More information about the lede-commits mailing list