summaryrefslogtreecommitdiffstats
path: root/src/sysupdate
diff options
context:
space:
mode:
authorAdrian Vovk <adrianvovk@gmail.com>2024-06-22 02:49:48 +0200
committerAdrian Vovk <adrianvovk@gmail.com>2024-08-22 22:00:44 +0200
commit0402bf682fb3b11bd4fd36969abf5426f24c3dde (patch)
tree04d813ea4a4fc03cf3995092198e9664c2190c4a /src/sysupdate
parentsysupdate: Fix resource_find_instance (diff)
downloadsystemd-0402bf682fb3b11bd4fd36969abf5426f24c3dde.tar.xz
systemd-0402bf682fb3b11bd4fd36969abf5426f24c3dde.zip
sysupdate: Check that --instances-max is in bounds
Otherwise user can pass in --instances-max=0 and crash sysupdate with an assertion failure.
Diffstat (limited to 'src/sysupdate')
-rw-r--r--src/sysupdate/sysupdate.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c
index dee8348bdb..5854535427 100644
--- a/src/sysupdate/sysupdate.c
+++ b/src/sysupdate/sysupdate.c
@@ -1067,6 +1067,10 @@ static int verb_vacuum(int argc, char **argv, void *userdata) {
assert(argc <= 1);
+ if (arg_instances_max < 1)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --instances-max argument must be >= 1 while vacuuming");
+
r = process_image(/* ro= */ false, &mounted_dir, &loop_device);
if (r < 0)
return r;
@@ -1090,6 +1094,10 @@ static int verb_update(int argc, char **argv, void *userdata) {
assert(argc <= 2);
version = argc >= 2 ? argv[1] : NULL;
+ if (arg_instances_max < 2)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --instances-max argument must be >= 2 while updating");
+
if (arg_reboot) {
/* If automatic reboot on completion is requested, let's first determine the currently booted image */