From dc1caf0d2ba8a58caf424bf631254c8e821229ec Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 18 Aug 2018 09:59:43 +0000 Subject: ntux_get_driver_ctx(): guard against a misplaced --cmd argument. --- src/driver/ntux_driver_ctx.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/driver') diff --git a/src/driver/ntux_driver_ctx.c b/src/driver/ntux_driver_ctx.c index 243a729..9443ab5 100644 --- a/src/driver/ntux_driver_ctx.c +++ b/src/driver/ntux_driver_ctx.c @@ -302,7 +302,20 @@ int ntux_get_driver_ctx( optv,0,cctx.cmd); /* initial argv scan: ... --cmd=xxx ... */ - for (parg=argv, cmdargv=0; *parg && !cmdargv; parg++) { + argv_scan(argv,optv,&ctx,0); + + /* invalid ntux arguments? */ + if (ctx.erridx && !ctx.unitidx) { + if (flags & NTUX_DRIVER_VERBOSITY_ERRORS) + argv_get( + argv,optv, + ARGV_VERBOSITY_ERRORS, + fdctx->fderr); + return -1; + } + + /* scan for --cmd */ + for (parg=argv, cmdargv=0; (parg<&argv[ctx.unitidx]) && !cmdargv; parg++) { if (!strcmp(*parg,"--cmd") && parg[1]) { cmdargv = &parg[2]; cmdmark = parg[2]; -- cgit v1.2.3