Ticket #129: openrc-0.4.1-start-stop-daemon.2.patch

File openrc-0.4.1-start-stop-daemon.2.patch, 1.2 KB (added by vaeth@mathematik.uni-wuerzburg.de, 20 months ago)

Patch for start-stop-daemon.c to postpone parse_schedule() after option parsing. No memory leak if --retry is used repeatedly.

  • src/rc/start-stop-daemon.c

     
    658658        mode_t numask; 
    659659        char **margv; 
    660660        unsigned int start_wait = 0; 
     661        bool retry = false; 
     662        char *retry_opt = NULL; 
    661663 
    662664        TAILQ_INIT(&schedule); 
    663665#ifdef DEBUG_MEMORY 
     
    694696                        break; 
    695697 
    696698                case 'R':  /* --retry <schedule>|<timeout> */ 
    697                         parse_schedule(optarg, sig); 
     699                        retry = true; 
     700                        if(retry_opt) 
     701                                free(retry_opt); 
     702                        if(optarg) 
     703                                retry_opt = xstrdup(optarg); 
     704                        else 
     705                                retry_opt = NULL; 
    698706                        break; 
    699707 
    700708                case 'S':  /* --start */ 
     
    837845            sig != SIGKILL) 
    838846                oknodo = true; 
    839847 
     848        if (stop && !sig) 
     849                sig = SIGTERM; 
     850 
     851        if (retry) { 
     852                parse_schedule(retry_opt, sig); 
     853                if (retry_opt) 
     854                        free(retry_opt); 
     855        } 
     856 
    840857        if (!exec) 
    841858                exec = startas; 
    842859        else if (!name) 
     
    853870        else if (exec) 
    854871                *--argv = exec; 
    855872 
    856         if (stop || sig) { 
     873        if (sig) { 
    857874                if (!*argv && !pidfile && !name && !uid) 
    858875                        eerrorx("%s: --stop needs --exec, --pidfile," 
    859876                                " --name or --user", applet); 
     
    954971        } 
    955972        margv = nav ? nav : argv; 
    956973 
    957         if (stop || sig) { 
    958                 if (!sig) 
    959                         sig = SIGTERM; 
     974        if (sig) { 
    960975                if (!stop) 
    961976                        oknodo = true; 
    962977                if (!TAILQ_FIRST(&schedule)) {