From 19b07a60b699f905adc94d389eaa02c8e9b763ec Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Feb 2022 00:55:14 +0100 Subject: mount: Fix deleting noauto/bind option After deleting an option, we have to let the loop continue from there instead of skipping another option. --- utils/mount.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils/mount.c b/utils/mount.c index 483b71fc..68fd6493 100644 --- a/utils/mount.c +++ b/utils/mount.c @@ -255,17 +255,26 @@ do_mount (struct fs *fs, int remount) /* Remove the `noauto' and `bind' options, since they're for us not the filesystem. */ - for (o = mntopts; o; o = argz_next (mntopts, mntopts_len, o)) + for (o = mntopts; o; ) { if (strcmp (o, MNTOPT_NOAUTO) == 0) - argz_delete (&mntopts, &mntopts_len, o); + { + argz_delete (&mntopts, &mntopts_len, o); + if (!mntopts || o >= mntopts + mntopts_len) + break; + continue; + } if (strcmp (o, "bind") == 0) { fs->mntent.mnt_type = strdup ("firmlink"); if (!fs->mntent.mnt_type) error (3, ENOMEM, "failed to allocate memory"); argz_delete (&mntopts, &mntopts_len, o); + if (!mntopts || o >= mntopts + mntopts_len) + break; + continue; } + o = argz_next (mntopts, mntopts_len, o); } ARGZ (append (&mntopts, &mntopts_len, options, options_len)); -- cgit v1.2.3