Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/imgact_shell.c
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | exec_shell_imgact(struct image_params *imgp) | ||||
*/ | */ | ||||
offset = interpe - interpb + 1; /* interpreter */ | offset = interpe - interpb + 1; /* interpreter */ | ||||
if (opte > optb) /* options (if any) */ | if (opte > optb) /* options (if any) */ | ||||
offset += opte - optb + 1; | offset += opte - optb + 1; | ||||
offset += strlen(fname) + 1; /* fname of script */ | offset += strlen(fname) + 1; /* fname of script */ | ||||
length = (imgp->args->argc == 0) ? 0 : | length = (imgp->args->argc == 0) ? 0 : | ||||
strlen(imgp->args->begin_argv) + 1; /* bytes to delete */ | strlen(imgp->args->begin_argv) + 1; /* bytes to delete */ | ||||
if (offset > imgp->args->stringspace + length) { | error = exec_args_adjust_args(imgp->args, length, offset); | ||||
if (error != 0) { | |||||
if (sname != NULL) | if (sname != NULL) | ||||
sbuf_delete(sname); | sbuf_delete(sname); | ||||
return (E2BIG); | return (error); | ||||
} | } | ||||
bcopy(imgp->args->begin_argv + length, imgp->args->begin_argv + offset, | |||||
imgp->args->endp - (imgp->args->begin_argv + length)); | |||||
offset -= length; /* calculate actual adjustment */ | |||||
imgp->args->begin_envv += offset; | |||||
imgp->args->endp += offset; | |||||
imgp->args->stringspace -= offset; | |||||
/* | /* | ||||
* If there was no arg[0] when we started, then the interpreter_name | * If there was no arg[0] when we started, then the interpreter_name | ||||
* is adding an argument (instead of replacing the arg[0] we started | * is adding an argument (instead of replacing the arg[0] we started | ||||
* with). And we're always adding an argument when we include the | * with). And we're always adding an argument when we include the | ||||
* full pathname of the original script. | * full pathname of the original script. | ||||
*/ | */ | ||||
if (imgp->args->argc == 0) | if (imgp->args->argc == 0) | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |