diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2021-04-01 18:37:50 +0100 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-04-01 17:43:18 +0000 |
commit | f27e858bae27a049f6f92dbe6b3ba4fcc28a9329 (patch) | |
tree | f6468b678de48170519144ba332f13f111464f66 /src/logic | |
parent | 2a100f3622881e3b85b312e2d5360c5f779acba1 (diff) | |
download | slibtool-f27e858bae27a049f6f92dbe6b3ba4fcc28a9329.tar.bz2 slibtool-f27e858bae27a049f6f92dbe6b3ba4fcc28a9329.tar.xz |
execute mode: fix NULL ptr deref with only one argument.
Diffstat (limited to 'src/logic')
-rw-r--r-- | src/logic/slbt_exec_execute.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/src/logic/slbt_exec_execute.c b/src/logic/slbt_exec_execute.c index f284512..bcf0913 100644 --- a/src/logic/slbt_exec_execute.c +++ b/src/logic/slbt_exec_execute.c @@ -46,38 +46,43 @@ int slbt_exec_execute( program = ectx->cargv[0]; script = ectx->cargv[1]; - /* wrapper */ - if ((size_t)snprintf(wrapper,sizeof(wrapper),"%s%s.exe.wrapper", - (script[0] == '/') ? "" : "./", - script) - >= sizeof(wrapper)) { - slbt_free_exec_ctx(actx); - return SLBT_BUFFER_ERROR(dctx); - } + if (script) { + /* wrapper */ + if ((size_t)snprintf(wrapper,sizeof(wrapper),"%s%s.exe.wrapper", + (script[0] == '/') ? "" : "./", + script) + >= sizeof(wrapper)) { + slbt_free_exec_ctx(actx); + return SLBT_BUFFER_ERROR(dctx); + } - /* exeref */ - if ((base = strrchr(script,'/'))) - base++; - else - base = script; + /* exeref */ + if ((base = strrchr(script,'/'))) + base++; + else + base = script; - strcpy(exeref,script); - mark = exeref + (base - script); - sprintf(mark,".libs/%s",base); + strcpy(exeref,script); + mark = exeref + (base - script); + sprintf(mark,".libs/%s",base); - /* swap vector */ - if (!(stat(script,&st)) && !(stat(wrapper,&st))) { - ectx->cargv[0] = wrapper; - ectx->cargv[1] = program; - ectx->cargv[2] = exeref; + /* swap vector */ + if (!(stat(script,&st)) && !(stat(wrapper,&st))) { + ectx->cargv[0] = wrapper; + ectx->cargv[1] = program; + ectx->cargv[2] = exeref; + } else { + script = program; + } + + /* execute mode */ + ectx->program = script; + ectx->argv = ectx->cargv; } else { - script = program; + ectx->program = program; + ectx->argv = ectx->cargv; } - /* execute mode */ - ectx->program = script; - ectx->argv = ectx->cargv; - /* step output */ if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT)) if (slbt_output_execute(dctx,ectx)) { |