Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/vfork_daemon_rexec.c

    r3232 r3621  
    7070
    7171#if ENABLE_FEATURE_PREFER_APPLETS
     72static jmp_buf die_jmp;
     73static void jump(void)
     74{
     75    /* Special case. We arrive here if NOFORK applet
     76     * calls xfunc, which then decides to die.
     77     * We don't die, but jump instead back to caller.
     78     * NOFORK applets still cannot carelessly call xfuncs:
     79     * p = xmalloc(10);
     80     * q = xmalloc(10); // BUG! if this dies, we leak p!
     81     */
     82    /* | 0x100 allows to pass zero exitcode (longjmp can't pass 0).
     83     * This works because exitcodes are bytes,
     84     * run_nofork_applet() ensures that by "& 0xff" */
     85    longjmp(die_jmp, xfunc_error_retval | 0x100);
     86}
     87
    7288struct nofork_save_area {
    7389    jmp_buf die_jmp;
     90    void (*die_func)(void);
    7491    const char *applet_name;
    7592    uint32_t option_mask32;
    76     int die_sleep;
    7793    uint8_t xfunc_error_retval;
    7894};
     
    8096{
    8197    memcpy(&save->die_jmp, &die_jmp, sizeof(die_jmp));
     98    save->die_func = die_func;
    8299    save->applet_name = applet_name;
     100    save->option_mask32 = option_mask32;
    83101    save->xfunc_error_retval = xfunc_error_retval;
    84     save->option_mask32 = option_mask32;
    85     save->die_sleep = die_sleep;
    86102}
    87103static void restore_nofork_data(struct nofork_save_area *save)
    88104{
    89105    memcpy(&die_jmp, &save->die_jmp, sizeof(die_jmp));
     106    die_func = save->die_func;
    90107    applet_name = save->applet_name;
     108    option_mask32 = save->option_mask32;
    91109    xfunc_error_retval = save->xfunc_error_retval;
    92     option_mask32 = save->option_mask32;
    93     die_sleep = save->die_sleep;
    94110}
    95111
     
    100116
    101117    save_nofork_data(&old);
    102 
    103     applet_name = APPLET_NAME(applet_no);
    104118
    105119    xfunc_error_retval = EXIT_FAILURE;
     
    134148        argc++;
    135149
    136     /* Special flag for xfunc_die(). If xfunc will "die"
    137      * in NOFORK applet, xfunc_die() sees negative
    138      * die_sleep and longjmp here instead. */
    139     die_sleep = -1;
    140 
     150    /* If xfunc "dies" in NOFORK applet, die_func longjmp's here instead */
     151    die_func = jump;
    141152    rc = setjmp(die_jmp);
    142153    if (!rc) {
     
    145156        char *tmp_argv[argc+1];
    146157        memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0]));
     158        applet_name = tmp_argv[0];
    147159        /* Finally we can call NOFORK applet's main() */
    148160        rc = applet_main[applet_no](argc, tmp_argv);
    149     } else { /* xfunc died in NOFORK applet */
    150         /* in case they meant to return 0... */
    151         if (rc == -2222)
    152             rc = 0;
     161    } else {
     162        /* xfunc died in NOFORK applet */
    153163    }
    154164
Note: See TracChangeset for help on using the changeset viewer.