Changeset 3333 in MondoRescue


Ignore:
Timestamp:
Jan 26, 2015, 8:20:04 AM (9 years ago)
Author:
Bruno Cornec
Message:
  • Fix a mondoarchive crash with option -v (Do not use finish before bkpinfo has been allocated but exit) (Philippe Lefevre)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/mondoarchive/mondoarchive.c

    r3208 r3333  
    165165    FILE *fin = NULL;
    166166
    167     /* Make sure I'm root; abort if not */
    168     if (getuid() != 0) {
    169         fprintf(stderr, "Please run as root.\r\n");
    170         finish(127);
    171     }
    172 
    173167    /* If -V, -v or --version then echo version no. and quit */
    174168    if (argc == 2 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V") || !strcmp(argv[argc - 1], "--version"))) {
    175169        printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
    176         finish(0);
     170        if (getuid() != 0) fprintf(stderr, "Please run the mondoarchive command as root.\n");
     171        exit(0);
     172    }
     173
     174    /* Make sure I'm root; abort if not */
     175    if (getuid() != 0) {
     176        fprintf(stderr, "Please run as root.\n");
     177        exit(127);
    177178    }
    178179
     
    184185    if (!(bkpinfo = (struct s_bkpinfo *)malloc(sizeof(struct s_bkpinfo)))) {
    185186        fprintf(stderr, "Cannot malloc bkpinfo\n");
    186         finish(-1);
    187     }
     187        exit(-1);
     188    }
     189    /*  Now on we can use finish to exit as bkpingo has been initialized */
    188190    log_msg(9, "reset_bkpinfo");
    189191    reset_bkpinfo();
Note: See TracChangeset for help on using the changeset viewer.