diff options
author | midipix <writeonce@midipix.org> | 2018-10-09 19:44:19 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-10-12 13:59:51 -0400 |
commit | 4fe92c4cff0594f66da78c946cbee5621cf23428 (patch) | |
tree | 829b31de5c67122c9b69e4f106c6f42b9a2ab8cb /src | |
parent | ecd0a790c814ad6faf8a3c1f69a18704cbdaa9e7 (diff) | |
download | ntux-4fe92c4cff0594f66da78c946cbee5621cf23428.tar.bz2 ntux-4fe92c4cff0594f66da78c946cbee5621cf23428.tar.xz |
ntux_get_driver_ctx(): properly identify the tool's pre- --cmd argument vector.
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/ntux_driver_ctx.c | 44 |
1 files changed, 34 insertions, 10 deletions
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<pargcap) && !cmdargv; parg++) { if (!strcmp(*parg,"--cmd") && parg[1]) { cmdargv = &parg[2]; cmdmark = parg[2]; @@ -325,6 +327,28 @@ int ntux_get_driver_ctx( } } + /* invalid ntux arguments? */ + if (!ctx.erridx) { + (void)0; + + } else if (&argv[ctx.erridx] >= 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; |