summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-04-01 18:37:50 +0100
committermidipix <writeonce@midipix.org>2021-04-01 17:43:18 +0000
commitf27e858bae27a049f6f92dbe6b3ba4fcc28a9329 (patch)
treef6468b678de48170519144ba332f13f111464f66 /src
parent2a100f3622881e3b85b312e2d5360c5f779acba1 (diff)
downloadslibtool-f27e858bae27a049f6f92dbe6b3ba4fcc28a9329.tar.bz2
slibtool-f27e858bae27a049f6f92dbe6b3ba4fcc28a9329.tar.xz
execute mode: fix NULL ptr deref with only one argument.
Diffstat (limited to 'src')
-rw-r--r--src/logic/slbt_exec_execute.c57
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)) {