| 586 | } |
| 587 | |
| 588 | static int |
| 589 | imgact_binmisc_exec(struct image_params *imgp) |
| 590 | { |
| 591 | const char *image_header = imgp->image_header; |
| 592 | const char *fname = NULL; |
| 593 | int error = 0; |
| 594 | #ifdef INVARIANTS |
| 595 | int argv0_cnt = 0; |
| 596 | #endif |
| 597 | size_t namelen, offset; |
| 598 | imgact_binmisc_entry_t *ibe; |
| 599 | struct sbuf *sname; |
| 600 | char *s, *d; |
| 601 | |
| 602 | sname = NULL; |
| 603 | namelen = 0; |
| 604 | /* Do we have an interpreter for the given image header? */ |
| 605 | INTERP_LIST_RLOCK(); |
| 606 | if ((ibe = imgact_binmisc_find_interpreter(image_header)) == NULL) { |
| 607 | error = -1; |
| 608 | goto done; |
| 609 | } |
| 610 | |
| 611 | /* No interpreter nesting allowed. */ |
| 612 | if (imgp->interpreted & IMGACT_BINMISC) { |
| 613 | error = ENOEXEC; |
| 614 | goto done; |
| 615 | } |
| 616 | |
| 617 | imgp->interpreted |= IMGACT_BINMISC; |
| 618 | |
| 619 | /* |
| 620 | * Don't bother with the overhead of putting fname together if we're not |
| 621 | * using #a. |
| 622 | */ |
| 623 | if (ibe->ibe_argv0_cnt != 0) { |
| 624 | if (imgp->args->fname != NULL) { |
| 625 | fname = imgp->args->fname; |
| 626 | } else { |
| 627 | /* Use the fdescfs(5) path for fexecve(2). */ |
| 628 | sname = sbuf_new_auto(); |
| 629 | sbuf_printf(sname, "/dev/fd/%d", imgp->args->fd); |
| 630 | sbuf_finish(sname); |
| 631 | fname = sbuf_data(sname); |
| 632 | } |
| 633 | |
| 634 | namelen = strlen(fname); |
| 635 | } |
| 636 | |
| 637 | /* |
| 638 | * We need to "push" the interpreter in the arg[] list. To do this, |
| 639 | * we first shift all the other values in the `begin_argv' area to |
| 640 | * provide the exact amount of room for the values added. Set up |
| 641 | * `offset' as the number of bytes to be added to the `begin_argv' |
| 642 | * area. ibe_interp_offset is the fixed offset from macros present in |
| 643 | * the interpreter string. |
| 644 | */ |
| 645 | offset = ibe->ibe_interp_length + ibe->ibe_interp_offset; |
nothing calls this directly
no test coverage detected