On Wed, 16 Oct 2024 08:17:19 +0000
Mingjin Ye <[email protected]> wrote:
> + for (i = 0; i < numargs; i++) {
> + if (strcmp(argv[i], "-b") == 0 ||
> + strcmp(argv[i], "--block") == 0)
> + block_num++;
> + if (strcmp(argv[i], "-a") == 0 ||
> + strcmp(argv[i], "--allow") == 0)
> + allow_num++;
> + }
The long options format allows the equals form, but this doesn't.
The argv scan for -a/-b/--allow/--block uses exact strcmp, so it won't
detect the --allow=DEVICE or --block=DEVICE joined form. If callers use
the = form, the parent's device list will be duplicated in the child's
arguments. Consider adding strncmp checks for the PREFIX_ALLOW and
PREFIX_BLOCK prefixes or use getopt_long to scan.
This is not a huge issue, but could you change and resubmit.