From 4fe92c4cff0594f66da78c946cbee5621cf23428 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 9 Oct 2018 19:44:19 -0400 Subject: ntux_get_driver_ctx(): properly identify the tool's pre- --cmd argument vector. --- src/driver/ntux_driver_ctx.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/driver/ntux_driver_ctx.c b/src/driver/ntux_driver_ctx.c index e2440b5..47718ce 100644 --- a/src/driver/ntux_driver_ctx.c +++ b/src/driver/ntux_driver_ctx.c @@ -259,6 +259,7 @@ int ntux_get_driver_ctx( size_t nunits; const char * program; char ** parg; + char ** pargcap; char ** cmdargv; char * cmdmark; char ** execargv; @@ -304,18 +305,19 @@ int ntux_get_driver_ctx( /* initial argv scan: ... --cmd=xxx ... */ 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; - } + /* position of last base ntux argument */ + if (ctx.erridx && ctx.unitidx) + pargcap = &argv[ctx.unitidx]; + + else if (ctx.erridx) + pargcap = &argv[ctx.erridx]; + + else + for (pargcap=argv; *pargcap; pargcap++) + (void)0; /* scan for --cmd */ - for (parg=argv, cmdargv=0; (parg<&argv[ctx.unitidx]) && !cmdargv; parg++) { + for (parg=argv, cmdargv=0; (parg= cmdargv) { + (void)0; + + } else if ((cctx.cmd == NTUX_CMD_SPAWN) && (ctx.erridx > ctx.unitidx)) { + (void)0; + + } else if ((cctx.cmd == NTUX_CMD_STRACE) && (ctx.erridx > ctx.unitidx)) { + (void)0; + + } else { + if (flags & NTUX_DRIVER_VERBOSITY_ERRORS) + argv_get( + argv,optv, + ARGV_VERBOSITY_ERRORS, + fdctx->fderr); + return -1; + } + /* process argv entries preceding --cmd */ if (cmdargv) { *cmdargv = 0; -- cgit v1.2.3