~ubuntu-branches/ubuntu/gutsy/avscan/gutsy

« back to all changes in this revision

Viewing changes to avscan/prochandle.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2007-08-12 14:22:25 UTC
  • mfrom: (1.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070812142225-2whp6690lilo2wg8
Tags: 3.2.1-openssl-2
Correctly handle DEB_BUILD_OPTIONS=nostrip (Closes: #436496).

Show diffs side-by-side

added added

removed removed

Lines of Context:
431
431
        const char *stdout_mode, const char *stderr_mode
432
432
)
433
433
{
434
 
        int argc;
 
434
        int argc, error_code;
435
435
        char **argv;
436
436
        FILE *stdout_fp, *stderr_fp;
437
437
        pid_t p;
493
493
        /* Object specified by command not executable? */
494
494
        if(access(argv[0], X_OK))
495
495
        {
 
496
            error_code = errno;
496
497
            strlistfree(argv, argc);
497
498
            if(stdout_fp != NULL)
498
499
                fclose(stdout_fp);
499
500
            if(stderr_fp != NULL)
500
501
                fclose(stderr_fp);
501
 
            errno = EACCES;
 
502
            errno = error_code;
502
503
            return(0);
503
504
        }
504
505
#endif
512
513
        {
513
514
          /* Forking error */
514
515
          case -1:
 
516
            error_code = errno;
515
517
            strlistfree(argv, argc);
516
518
            if(stdout_fp != NULL)
517
519
                fclose(stdout_fp);
518
520
            if(stderr_fp != NULL)
519
521
                fclose(stderr_fp);
520
 
            errno = ENOMEM;
 
522
            errno = error_code;
521
523
            return(0);
522
524
            break;
523
525
 
600
602
        int *status
601
603
)
602
604
{
603
 
        int argc;
 
605
        int argc, error_code;
604
606
        char **argv;
605
607
        FILE *stdout_fp, *stderr_fp;
606
608
        pid_t p;
650
652
        argv = (char **)realloc(argv, (argc + 1) * sizeof(char *));
651
653
        if(argv == NULL)
652
654
        {
 
655
            error_code = errno;
653
656
            if(stdout_fp != NULL)
654
657
                fclose(stdout_fp);
655
658
            if(stderr_fp != NULL)
656
659
                fclose(stderr_fp);
657
 
            errno = ENOMEM;
 
660
            errno = error_code;
658
661
            return(0);
659
662
        }
660
663
        argv[argc] = NULL;
664
667
           access(argv[0], X_OK)
665
668
        )
666
669
        {
 
670
            error_code = errno;
667
671
            strlistfree(argv, argc);
668
672
            if(stdout_fp != NULL)
669
673
                fclose(stdout_fp);
670
674
            if(stderr_fp != NULL)
671
675
                fclose(stderr_fp);
672
 
            errno = EACCES;
 
676
            errno = error_code;
673
677
            return(0);
674
678
        }
675
679
 
679
683
        {
680
684
          /* Forking error */
681
685
          case -1:
 
686
            error_code = errno;
682
687
            strlistfree(argv, argc);
683
688
            if(stdout_fp != NULL)
684
689
                fclose(stdout_fp);
685
690
            if(stderr_fp != NULL)
686
691
                fclose(stderr_fp);
687
 
            errno = ENOMEM;
 
692
            errno = error_code;
688
693
            return(0);
689
694
            break;
690
695