Changeset 2331 in MondoRescue


Ignore:
Timestamp:
Aug 18, 2009, 3:25:29 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3342@localhost: bruno | 2009-08-14 00:46:51 +0200

  • Another round of strcpy suppressions
  • find_home_of_exe() now allocates memory which has to be freed by the caller
  • Supress useless sz_last_suffix()
  • mr_getline now has the same interface as the other mr_mem functions
  • valgrind and compiler warnings fixes
Location:
branches/2.2.10/mondo/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2330 r2331  
    404404    if (bkpinfo->backup_media_type == dvd) {
    405405#ifdef DVDRWFORMAT
    406         if (!find_home_of_exe("dvd+rw-format")) {
    407             fatal_error
    408                 ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
    409         }
     406        tmp = find_home_of_exe("dvd+rw-format");
     407        if (!tmp) {
     408            mr_free(tmp);
     409            fatal_error("Cannot find dvd+rw-format. Please install it or fix your PATH.");
     410        }
     411        mr_free(tmp);
    410412#endif
    411         if (!find_home_of_exe("growisofs")) {
    412             fatal_error
    413                 ("Cannot find growisofs. Please install it or fix your PATH.");
    414         }
     413        tmp = find_home_of_exe("growisofs");
     414        if (!tmp) {
     415            mr_free(tmp);
     416            fatal_error("Cannot find growisofs. Please install it or fix your PATH.");
     417        }
     418        mr_free(tmp);
    415419    }
    416420
     
    28772881        mr_asprintf(checksum_line, "IGNORE");
    28782882        log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename);
    2879         if ( !find_home_of_exe("ntfsresize")) {
     2883        tmp = find_home_of_exe("ntfsresize");
     2884        if (!tmp) {
     2885            mr_free(tmp);
    28802886            fatal_error("ntfsresize not found");
    28812887        }
     2888        mr_free(tmp);
     2889
    28822890        mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    28832891        log_it("command = %s", command);
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2330 r2331  
    709709    }
    710710
    711     if (!find_home_of_exe("afio")) {
    712         if (find_home_of_exe("star")) {
     711    tmp1 = find_home_of_exe("afio");
     712    if (!tmp1) {
     713        mr_free(tmp1);
     714        tmp1 = find_home_of_exe("star");
     715        if (tmp1) {
     716            mr_free(tmp1);
    713717            flag_set['R'] = TRUE;
    714718            log_msg(1, "Using star instead of afio");
    715719        } else {
    716             fatal_error
    717                 ("Neither afio nor star is installed. Please install at least one.");
    718         }
    719     }
     720            mr_free(tmp1);
     721            fatal_error("Neither afio nor star is installed. Please install at least one.");
     722        }
     723    }
     724    mr_free(tmp1);
    720725
    721726    if (flag_set['R']) {
     
    724729            fatal_error("You may not use star and lzop at the same time.");
    725730        }
    726         if (!find_home_of_exe("star")) {
    727             fatal_error
    728                 ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    729         }
     731        tmp1 = find_home_of_exe("star");
     732        if (!tmp1) {
     733            mr_free(tmp1);
     734            fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     735        }
     736        mr_free(tmp1);
    730737    }
    731738
     
    919926        }
    920927        if (! bkpinfo->restore_data) {
    921             if (!find_home_of_exe("growisofs")) {
     928            tmp1 = find_home_of_exe("growisofs");
     929            if (!tmp1) {
     930                mr_free(tmp1);
    922931                fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    923932            }
    924             if (!find_home_of_exe("dvd+rw-format")) {
     933            mr_free(tmp1);
     934
     935            tmp1 = find_home_of_exe("dvd+rw-format");
     936            if (!tmp1) {
     937                mr_free(tmp1);
    925938                fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    926939            }
     940            mr_free(tmp1);
     941
    927942            if (!flag_set['s']) {
    928943                sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
     
    10461061    }
    10471062    if (flag_set['z']) {
    1048         if (find_home_of_exe("getfattr")) {
     1063        tmp1 = find_home_of_exe("getfattr");
     1064        if (tmp1) {
    10491065            mr_asprintf(g_getfattr,"getfattr");
    10501066        }
    1051         if (find_home_of_exe("getfacl")) {
     1067        mr_free(tmp1);
     1068
     1069        tmp1 = find_home_of_exe("getfacl");
     1070        if (tmp1) {
    10521071            mr_asprintf(g_getfacl,"getfacl");
    10531072        }
     1073        mr_free(tmp1);
    10541074    }
    10551075
     
    13321352
    13331353    if (flag_set['Q']) {
    1334         i = which_boot_loader(tmp1);
    1335         log_msg(3, "boot loader is %c, residing at %s", i, tmp1);
    1336         printf("boot loader is %c, residing at %s\n", i, tmp1);
    1337         mr_free(tmp1);
     1354        i = which_boot_loader(NULL);
     1355        log_msg(3, "boot loader is %c", i);
     1356        printf("boot loader is %c\n", i);
    13381357        finish(0);
    13391358    }
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2330 r2331  
    509509    /*@ buffers ************************ */
    510510    char *tmp = NULL;
     511    char *tmp1 = NULL;
    511512    char *cdr_exe = NULL;
    512513    char *command = NULL;
     
    523524    }
    524525    run_program_and_log_output("insmod ide-scsi", -1);
    525     if (find_home_of_exe("cdrecord")) {
     526    tmp = find_home_of_exe("cdrecord");
     527    if (tmp) {
    526528        mr_asprintf(cdr_exe, "cdrecord");
    527529    } else {
    528530        mr_asprintf(cdr_exe, "dvdrecord");
    529531    }
    530     if (find_home_of_exe(cdr_exe)) {
     532    mr_free(tmp);
     533
     534    tmp1 = find_home_of_exe(cdr_exe);
     535    if (tmp1) {
    531536        mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);
    532537        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    533538        mr_free(command);
    534539    }
     540    mr_free(tmp1);
     541
    535542    if ((tmp == NULL) || (strlen(tmp) < 2)) {
    536543        mr_free(tmp);
     
    603610    make_hole_for_dir(mountpoint);
    604611
    605     if (find_home_of_exe("cdrecord")) {
     612    tmp = find_home_of_exe("cdrecord");
     613    if (tmp) {
    606614        mr_asprintf(cdr_exe, "cdrecord");
    607615    } else {
    608616        mr_asprintf(cdr_exe, "dvdrecord");
    609617    }
    610 
    611     if (!find_home_of_exe(cdr_exe)) {
     618    mr_free(tmp);
     619
     620    tmp = find_home_of_exe(cdr_exe);
     621    if (!tmp) {
    612622        mr_asprintf(output, "/dev/cdrom");
    613623        log_msg(4, "Can't find cdrecord; assuming %s", output);
     
    616626            log_msg(4, "That didn't work. Sorry.");
    617627            mr_free(output);
    618             return(output);
    619         } else {
    620             return(output);
    621         }
    622     }
     628        }
     629        mr_free(tmp);
     630        return(output);
     631    }
     632    mr_free(tmp);
    623633
    624634    mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
     
    9921002        retval = 0;
    9931003    } else {
    994         mr_getline(&good_formats, pin);
     1004        mr_getline(good_formats, pin);
    9951005        if (pclose(pin)) {
    9961006            log_OS_error("Cannot pclose good formats");
     
    23442354        if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
    23452355            count_grubs++;
     2356            /* BERLIOS : removed as I don't think it's mandatory here
    23462357            mr_free(which_device);
    23472358            mr_asprintf(which_device, "%s", current_drive);
     2359            */
    23482360            break;
    23492361        }
    23502362        if (does_string_exist_in_boot_block(current_drive, "LILO")) {
    23512363            count_lilos++;
     2364            /* BERLIOS : removed as I don't think it's mandatory here
    23522365            mr_free(which_device);
    23532366            mr_asprintf(which_device, "%s", current_drive);
     2367            */
    23542368            break;
    23552369        }
     
    23882402            if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
    23892403                count_grubs++;
     2404                /* BERLIOS : removed as I don't think it's mandatory here
    23902405                mr_free(which_device);
    23912406                mr_asprintf(which_device, "%s", current_drive);
     2407                */
    23922408                break;
    23932409            }
    23942410            if (does_string_exist_in_boot_block(current_drive, "LILO")) {
    23952411                count_lilos++;
     2412                /* BERLIOS : removed as I don't think it's mandatory here
    23962413                mr_free(which_device);
    23972414                mr_asprintf(which_device, "%s", current_drive);
     2415                */
    23982416                break;
    23992417            }
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2327 r2331  
    527527    char *syscall_pout = NULL;
    528528    char *incoming;
    529     char *current_subset_file, *current_master_file;
     529    char *current_subset_file;
     530    char *current_master_file = NULL;
    530531    char *masklist = NULL;
    531532    int retval = 0;
     
    551552    malloc_string(incoming);
    552553    malloc_string(current_subset_file);
    553     malloc_string(current_master_file);
    554554    mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir);
    555555    mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist);
     
    558558
    559559    sort_file(masklist);
    560     current_subset_file[0] = current_master_file[0] = '\0';
     560    current_subset_file[0] = '\0';
    561561
    562562    mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);
     
    594594    (void)fgets(incoming, MAX_STR_LEN, pin);
    595595    while (!feof(pin) && !feof(faclin)) {
    596 //      printf("incoming = %s", incoming);
    597 
    598         strcpy(current_master_file, incoming + 8);
     596        mr_asprintf(current_master_file, "%s", incoming + 8);
    599597
    600598        p = current_subset_file;
     
    635633            log_msg(my_depth, "Copying master %s", q);
    636634        }
    637 //      if (!i) { printf("Match --- %s\n", q); }
    638635
    639636        while (!feof(pin) && strncmp(incoming, "# file: ", 8)) {
    640637            if (!i) {
    641 
    642 //    printf("%s", incoming);
    643 
    644638                fputs(incoming, pout);
    645639            }
     
    649643            (void)fgets(current_subset_file, MAX_STR_LEN, faclin);
    650644        }
     645        mr_free(current_master_file);
    651646    }
    652647    while (!feof(pin)) {
     
    663658
    664659    paranoid_free(current_subset_file);
    665     paranoid_free(current_master_file);
    666660    paranoid_free(incoming);
    667661    return (retval);
     
    669663
    670664
    671 int set_fattr_list(char *masklist, char *fattr_fname)
    672 {
    673     if (find_home_of_exe("setfattr")) {
     665int set_fattr_list(char *masklist, char *fattr_fname) {
     666
     667    char *tmp = NULL;
     668
     669    tmp = find_home_of_exe("setfattr");
     670    if (tmp) {
     671        mr_free(tmp);
    674672        return (set_EXAT_list(masklist, fattr_fname, "setfattr"));
    675673    } else {
     674        mr_free(tmp);
    676675        log_msg(1, "ERROR: set_EXAT_list: setfattr doesn't exist");
    677676        return(0);
     
    681680
    682681
    683 int set_acl_list(char *masklist, char *acl_fname)
    684 {
    685     if (find_home_of_exe("setfacl")) {
     682int set_acl_list(char *masklist, char *acl_fname) {
     683
     684    char *tmp = NULL;
     685
     686    tmp = find_home_of_exe("setfacl");
     687    if (tmp) {
     688        mr_free(tmp);
    686689        return (set_EXAT_list(masklist, acl_fname, "setfacl"));
    687690    } else {
     691        mr_free(tmp);
    688692        log_msg(1, "ERROR: set_EXAT_list: setfacl doesn't exist");
    689693        return(0);
     
    17701774    char *fname;
    17711775    char *tmp;
    1772     size_t len = 0;             // Scrub's patch doesn't work without that
    1773 
    1774 //  log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");
     1776    size_t len = 0;
     1777
    17751778    malloc_string(fname);
    17761779    malloc_string(tmp);
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2328 r2331  
    317317 * @return The full path to the executable, or "" if it does not exist, or NULL if @c file could not be found.
    318318 * @note The returned string points to static storage that will be overwritten with each call.
    319  * @bug The checks with @c file and @c dirname seem pointless. If @c incoming is "", then you're calling
     319 * @bug The checks with @c file and @c dirname seem pointless. If @c output is "", then you're calling
    320320 * <tt>dirname 2\>/dev/null</tt> or <tt>file 2\>/dev/null | cut -d':' -f1 2\>/dev/null</tt>, which basically amounts
    321321 * to nothing.
     
    324324{
    325325    /*@ buffers ********************* */
    326     static char output[MAX_STR_LEN];
    327     char *incoming;
     326    char *output = NULL;
    328327    char *command = NULL;
    329328
    330     malloc_string(incoming);
    331     incoming[0] = '\0';
    332329    /*@******************************* */
    333330
    334331    assert_string_is_neither_NULL_nor_zerolength(fname);
    335332    mr_asprintf(command, "which %s 2> /dev/null", fname);
    336     strcpy(incoming, call_program_and_get_last_line_of_output(command));
    337     mr_free(command);
    338     if (incoming[0] == '\0') {
     333    mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     334    mr_free(command);
     335    if (output[0] == '\0') {
    339336        if (system("which file > /dev/null 2> /dev/null")) {
    340             paranoid_free(incoming);
    341             output[0] = '\0';
     337            mr_free(output);
    342338            return (NULL);      // forget it :)
    343339        }
    344         mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    345         strcpy(incoming, call_program_and_get_last_line_of_output(command));
     340        mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", output);
     341        mr_free(output);
     342        mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
    346343        mr_free(command);
    347344    }
    348     if (incoming[0] == '\0')    // yes, it is == '\0' twice, not once :)
    349     {
    350         mr_asprintf(command, "dirname %s 2> /dev/null", incoming);
    351         strcpy(incoming, call_program_and_get_last_line_of_output(command));
     345    if (output[0] == '\0') {
     346        mr_asprintf(command, "dirname %s 2> /dev/null", output);
     347        mr_free(output);
     348        mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
    352349        mr_free(command);
    353350    }
    354     strcpy(output, incoming);
     351
    355352    if (output[0] != '\0' && does_file_exist(output)) {
    356         log_msg(4, "find_home_of_exe () --- Found %s at %s", fname,
    357                 incoming);
     353        log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output);
    358354    } else {
    359         output[0] = '\0';
     355        mr_free(output);
    360356        log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
    361357    }
    362     paranoid_free(incoming);
    363     if (!output[0]) {
    364         return (NULL);
    365     } else {
    366         return (output);
    367     }
     358    return (output);
    368359}
    369360
     
    427418
    428419    /*@ buffers ***************************************************** */
    429     char lastline[MAX_STR_LEN];
     420    char *lastline = NULL;
    430421    char *command = NULL;
    431422    /*@ pointers **************************************************** */
     
    440431    if (i < 0) {
    441432        mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    442         strcpy(lastline, call_program_and_get_last_line_of_output(command));
     433        mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
    443434        mr_free(command);
    444435        if (!lastline[0]) {
     436            mr_free(lastline);
    445437            return (0);
    446438        }
    447439    } else {
    448         strcpy(lastline, err_log_lines[i]);
     440        mr_asprintf(lastline, "%s", err_log_lines[i]);
    449441    }
    450442
     
    454446    }
    455447    if (!p) {
     448        mr_free(lastline);
    456449        return (0);
    457450    }
     
    461454        p++;
    462455    }
     456    mr_free(lastline);
     457
    463458    i = atoi(p);
    464 
    465459    return (i);
    466460}
     
    550544    char stub_fname[1000];
    551545    char curr_fname[1000];
    552     char curr_cksum[1000];
     546    char *curr_cksum = NULL;
    553547    char *tmp = NULL;
    554548
     
    589583        mr_free(tmp);
    590584
    591         strcpy(curr_cksum, calc_file_ugly_minichecksum(curr_fname));
     585        mr_asprintf(curr_cksum, "%s", calc_file_ugly_minichecksum(curr_fname));
    592586        fprintf(fout, "%s\t%s\n", curr_fname, curr_cksum);
     587        mr_free(curr_cksum);
     588
    593589        if (counter++ > 12) {
    594590            current_time = get_time();
     
    719715    char *command = NULL;
    720716    char *mountlist = NULL;
    721     char sz_res[MAX_STR_LEN];
     717    char *sz_res = NULL;
    722718    long file_len_K;
    723719
     
    727723
    728724    log_it(command);
    729     strcpy(sz_res, call_program_and_get_last_line_of_output(command));
     725    mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
    730726    file_len_K = atol(sz_res);
    731727    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     728    mr_free(sz_res);
    732729    mr_free(command);
    733730
     
    745742    char *fname;
    746743    char *biggielist = NULL;
    747     char *comment = NULL;
    748744    char *tmp = NULL;
    749745    char *command = NULL;
     
    752748    long scratchL = 0;
    753749    long file_len_K;
    754 
    755     int res = 0;
    756750
    757751    /*@ pointers *************************************************** */
     
    778772            if (0 == strncmp(fname, "/dev/", 5)) {
    779773                if (is_dev_an_NTFS_dev(fname)) {
    780                     if ( !find_home_of_exe("ntfsresize")) {
     774                    tmp = find_home_of_exe("ntfsresize");
     775                    if (!tmp) {
     776                        mr_free(tmp);
    781777                        fatal_error("ntfsresize not found");
    782778                    }
     779                    mr_free(tmp);
     780
    783781                    mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    784782                    log_it("command = %s", command);
     
    10051003    /*@ Char buffers ** */
    10061004    char *command = NULL;
    1007     char tmp[MAX_STR_LEN];
     1005    char *tmp = NULL;
    10081006    int res = 0;
    10091007
    1010     mvaddstr_and_log_it(g_currentY, 0,
    1011                         "Copying Mondo's core files to the scratch directory");
     1008    mvaddstr_and_log_it(g_currentY, 0, "Copying Mondo's core files to the scratch directory");
    10121009
    10131010    log_msg(4, "g_mondo_home='%s'", g_mondo_home);
     
    10331030    }
    10341031
    1035     strcpy(tmp,
    1036            call_program_and_get_last_line_of_output("which mondorestore"));
     1032    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
    10371033    if (!tmp[0]) {
    1038         fatal_error
    1039             ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
     1034        mr_free(tmp);
     1035        fatal_error("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
    10401036    }
    10411037    mr_asprintf(command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     1038    mr_free(tmp);
     1039
    10421040    res = run_program_and_log_output(command, FALSE);
    10431041    mr_free(command);
     
    12701268
    12711269/**
    1272  * Get the last suffix of @p instr.
    1273  * If @p instr was "httpd.log.gz", we would return "gz".
    1274  * @param instr The filename to get the suffix of.
    1275  * @return The suffix (without a dot), or "" if none.
    1276  * @note The returned string points to static storage that will be overwritten with each call.
    1277  */
    1278 char *sz_last_suffix(char *instr)
    1279 {
    1280     static char outstr[MAX_STR_LEN];
    1281     char *p;
    1282 
    1283     p = strrchr(instr, '.');
    1284     if (!p) {
    1285         outstr[0] = '\0';
    1286     } else {
    1287         strcpy(outstr, p);
    1288     }
    1289     return (outstr);
    1290 }
    1291 
    1292 
    1293 /**
    12941270 * Determine whether a file is compressed. This is done
    12951271 * by reading through the "do-not-compress-these" file distributed with Mondo.
     
    12991275bool is_this_file_compressed(char *filename)
    13001276{
    1301     char do_not_compress_these[MAX_STR_LEN];
     1277    char *do_not_compress_these = NULL;
    13021278    char *tmp = NULL;
    13031279    char *p;
     
    13151291    }
    13161292    /* BERLIOS: This is just plain WRONG !! */
    1317     strcpy(do_not_compress_these,last_line_of_file(tmp));
     1293    mr_asprintf(do_not_compress_these, "%s", last_line_of_file(tmp));
    13181294    mr_free(tmp);
    13191295
     
    13251301        if (!strcmp(q, tmp)) {
    13261302            mr_free(tmp);
     1303            mr_free(do_not_compress_these);
    13271304            return (TRUE);
    13281305        }
     
    13321309        mr_free(tmp);
    13331310    }
     1311    mr_free(do_not_compress_these);
    13341312    return (FALSE);
    13351313}
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2325 r2331  
    589589// BACKUP
    590590    int res = -1;
    591     char*command = NULL;
     591    char *command = NULL;
    592592
    593593    if (!does_file_exist(input_device)) {
    594594        fatal_error("input device does not exist");
    595595    }
    596     if ( !find_home_of_exe("ntfsclone")) {
     596    command = find_home_of_exe("ntfsclone");
     597    if (!command) {
     598        mr_free(command);
    597599        fatal_error("ntfsclone not found");
    598600    }
     601    mr_free(command);
     602
    599603    mr_asprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
    600604    res = run_program_and_log_output(command, 5);
     
    639643    /*@ buffers *********************************************************** */
    640644    char *command = NULL;
    641     char *title;
     645    char *title = NULL;
    642646    /*@ pointers ********************************************************** */
    643647    static int chldres = 0;
     
    650654    *pchild_result = 999;
    651655
    652     malloc_string(title);
    653     strcpy(title, tt);
    654656    mr_asprintf(command, "%s 2>> %s", cmd, MONDO_LOGFILE);
    655657    log_msg(3, "command = '%s'", command);
     
    659661
    660662    log_msg(8, "Parent running");
     663    mr_asprintf(title, "%s", tt);
    661664    open_evalcall_form(title);
     665    mr_free(title);
     666
    662667    for (sleep(1); command[0] != '\0'; sleep(1)) {
    663668        pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
     
    669674        if (pcno <= 5 && last_pcno >= 40) {
    670675            close_evalcall_form();
    671             strcpy(title, "Verifying...");
     676            mr_asprintf(title, "Verifying...");
    672677            open_evalcall_form(title);
     678            mr_free(title);
    673679        }
    674680        if (counter++ >= 5) {
     
    690696    }
    691697    log_msg(3, "Parent res = %d", res);
    692     paranoid_free(title);
    693698    return (res);
    694699}
    695 
    696 
    697700
    698701
     
    709712    char *command = NULL;
    710713
    711     if ( !find_home_of_exe("ntfsclone")) {
     714    command = find_home_of_exe("ntfsclone");
     715    if (!command) {
     716        mr_free(command);
    712717        fatal_error("ntfsclone not found");
    713718    }
     719    mr_free(command);
     720
    714721    mr_asprintf(command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
    715722    res = run_program_and_log_output(command, 5);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2330 r2331  
    6060    char tmp = NULL;
    6161    char *device = NULL;
    62     char mountpoint[MAX_STR_LEN];
    6362
    6463    char *flaws_str = NULL;
     
    104103                continue;
    105104            }
    106             strcpy(mountpoint, mountlist->el[pos].mountpoint);
    107105            /* is it too big? */
    108106            if (curr_part_no > 'h') {
     
    186184
    187185        device = build_partition_name(drive, curr_part_no);
    188         strcpy(mountpoint, mountlist->el[pos].mountpoint);
    189186        if (pos > 0 && !npos) {
    190187            /* gap in the partition list? */
     
    271268                    continue;
    272269                }
    273                 strcpy(mountpoint, mountlist->el[pos].mountpoint);
    274270                /* is it too big? */
    275271                if (curr_part_no > 'h') {
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2325 r2331  
    256256
    257257    log_to_screen("I am looking for your tape streamer. Please wait.");
    258     if (find_home_of_exe("cdrecord")) {
    259         mr_asprintf(&cdr_exe, "cdrecord");
    260     } else {
    261         mr_asprintf(&cdr_exe, "dvdrecord");
    262     }
     258    tmp = find_home_of_exe("cdrecord");
     259    if (tmp) {
     260        mr_asprintf(cdr_exe, "cdrecord");
     261    } else {
     262        mr_asprintf(cdr_exe, "dvdrecord");
     263    }
     264    mr_free(tmp);
     265
    263266    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    264     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     267    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    265268    mr_free(command);
    266269
     
    269272        mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE);
    270273        mr_free(tmp);
     274        mr_free(tmp);
    271275        return(dev);
    272276    }
     
    274278
    275279    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe);
    276     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     280    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    277281    mr_free(command);
    278282
     
    280284        log_it("Could not find tape device");
    281285        mr_free(tmp);
    282         return(dev);
     286        return(NULL);
    283287    }
    284288    mr_free(tmp);
     289
    285290    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);
    286291    mr_free(cdr_exe);
    287292
    288     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     293    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    289294    mr_free(command);
    290 
    291295
    292296    mr_asprintf(dev, "%s", "/dev/st");
    293297    mr_strcat(dev, tmp);            // e.g. '/dev/st0' becomes '/dev/stN'
    294298    mr_free(tmp);
     299
    295300    res = 0;
    296301    if (!mt_says_tape_exists(dev)) {
     
    321326    }
    322327
    323     mr_asprintf(&tmp, call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     328    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(" cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' |  grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
    324329
    325330    if (mt_says_tape_exists(dev)) {
     
    328333        log_it("Turning %s", dev);
    329334        mr_free(tmp);
    330         mr_asprintf(&tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
     335        mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
    331336        mr_free(dev);
    332337        mr_asprintf(&dev, "/dev/os%s", tmp);
     
    342347    log_it("res=%d; dev=%s", res, dev);
    343348
    344     if (res) {
     349    if (dev) {
     350        log_it("At this new point, dev = %s and res = %d", dev, res);
     351    } else {
     352        log_it("At this new point, dev is NULL and res = %d", dev, res);
    345353        mr_free(tmp);
    346         return (dev);
     354        return(NULL);
    347355    }
    348356
     
    351359    }
    352360    mr_free(tmp);
    353     return (NULL);
     361    return(dev);
    354362}
    355363
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2329 r2331  
    418418    char *tmp = NULL;
    419419    char *p = NULL;
    420     char call_before_iso_user = NULL;
     420    char *call_before_iso_user = NULL;
    421421    char *iso_dev = NULL;
    422422    char *iso_mnt = NULL;
     
    494494
    495495    if (bkpinfo->backup_media_type == dvd) {
    496         if (find_home_of_exe("growisofs")) {
     496        tmp = find_home_of_exe("growisofs");
     497        if (tmp) {
    497498            strcpy(cdr_exe, "growisofs");
    498499        }                       // unlikely to be used
    499500        else {
     501            mr_free(tmp);
    500502            fatal_error("Please install growisofs.");
    501503        }
     504        mr_free(tmp);
     505
    502506        if (bkpinfo->nonbootable_backup) {
    503507            mr_asprintf(mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
     
    554558            mr_asprintf(extra_cdrom_params, "blank=fast ");
    555559        }
    556         if (find_home_of_exe("cdrecord")) {
     560        tmp = find_home_of_exe("cdrecord");
     561        if (tmp) {
    557562            strcpy(cdr_exe, "cdrecord");
    558         } else if (find_home_of_exe("dvdrecord")) {
    559             strcpy(cdr_exe, "dvdrecord");
    560563        } else {
    561             fatal_error("Please install either cdrecord or dvdrecord.");
    562         }
     564            mr_free(tmp);
     565            tmp = find_home_of_exe("dvdrecord");
     566            if (tmp) {
     567                strcpy(cdr_exe, "dvdrecord");
     568            } else {
     569                mr_free(tmp);
     570                fatal_error("Please install either cdrecord or dvdrecord.");
     571            }
     572        }
     573        mr_free(tmp);
     574
    563575        if (bkpinfo->nonbootable_backup) {
    564576            mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT);
     
    10001012    }
    10011013
    1002     if (!find_home_of_exe("cmp")) {
    1003         if (!find_home_of_exe("true")) {
    1004             whine_if_not_found("cmp");
     1014    tmp = find_home_of_exe("cmp");
     1015    if (!tmp) {
     1016        mr_free(tmp);
     1017        tmp = find_home_of_exe("true");
     1018        if (!tmp) {
     1019            retval += whine_if_not_found("cmp");
    10051020        } else {
    1006             log_to_screen
    1007                 ("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you.");
    1008             if (run_program_and_log_output
    1009                 ("cp -f `which true` /usr/bin/cmp", 0)) {
     1021            log_to_screen("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you.");
     1022            if (run_program_and_log_output("cp -f `which true` /usr/bin/cmp", 0)) {
     1023                mr_free(tmp);
    10101024                fatal_error("Failed to create dummy 'cmp' file.");
    10111025            }
    10121026        }
    10131027    }
    1014     run_program_and_log_output
    1015         ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
     1028    mr_free(tmp);
     1029
     1030    run_program_and_log_output("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
    10161031    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""));
    10171032    if (strcmp("", tmp)) {
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2324 r2331  
    750750        if (g_text_mode) {
    751751            printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q--- [%s]\n-->  ", title, b, input);
    752             mr_getline(&output, stdin);
     752            mr_getline(output, stdin);
    753753            if (! strcmp(output,"\n")) {
    754754                /* take default if ENTER was typed */
  • branches/2.2.10/mondo/src/include/mr_mem.h

    r2323 r2331  
    2020#define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)
    2121#define mr_asprintf(x,y,args...) mr_asprintf_int((char **)&x,__LINE__,__FILE__,y,## args)
    22 #define mr_getline(x,y) mr_getline_int(x,y,__LINE__,__FILE__)
     22#define mr_getline(x,y) mr_getline_int((char **)&x,y,__LINE__,__FILE__)
    2323#define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__)
    2424#define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__)
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2330 r2331  
    240240    log_it("STARTING");
    241241    log_msg(1, "OK, opened i-want-my-lvm. Shutting down LVM volumes...");
    242     if (find_home_of_exe("lvm"))    // found it :) cool
     242    tmp1 = find_home_of_exe("lvm");
     243    if (tmp1)   // found it :) cool
    243244    {
    244245        strcpy(lvscan_sz, "lvm lvscan");
     
    258259        strcpy(vgremove_sz, "vgremove");
    259260    }
     261    mr_free(tmp1);
     262
    260263    mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
    261264    run_program_and_log_output(tmp1, 5);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2329 r2331  
    390390            mr_strcat(additional_parameters, "-o ro");
    391391        }
    392         if (find_home_of_exe("setfattr")) {
     392        tmp = find_home_of_exe("setfattr");
     393        if (tmp) {
    393394            mr_strcat(additional_parameters, ",user_xattr");
    394395        }
    395         if (find_home_of_exe("setfacl")) {
     396        mr_free(tmp);
     397
     398        tmp = find_home_of_exe("setfacl");
     399        if (tmp) {
    396400            mr_strcat(additional_parameters, ",acl");
    397401        }
     402        mr_free(tmp);
    398403    }
    399404
     
    870875    mr_asprintf(g_getfacl,"setfacl");
    871876    log_msg(1, "We will restore ACLs");
    872     if (! find_home_of_exe("setfacl")) {
     877    tmp = find_home_of_exe("setfacl");
     878    if (!tmp) {
    873879        log_msg(1, "Unable to restore ACLs as no setfacl found");
    874880    }
     881    mr_free(tmp);
    875882}
    876883mr_free(value);
     
    880887    mr_asprintf(g_getfattr,"setfattr");
    881888    log_msg(1, "We will restore XATTRs");
    882     if (! find_home_of_exe("setfattr")) {
     889    tmp = find_home_of_exe("setfattr");
     890    if (!tmp) {
    883891        log_msg(1, "Unable to restore XATTRs as no setfattr found");
    884892    }
     893    mr_free(tmp);
    885894}
    886895mr_free(value);
     
    14371446 * @note The returned string points to static storage that will be overwritten with each call.
    14381447 */
    1439 char *find_my_editor(void)
    1440 {
     1448char *find_my_editor(void) {
     1449   
     1450    char *tmp = NULL;
    14411451    static char output[MAX_STR_LEN];
    1442     if (find_home_of_exe("pico")) {
     1452
     1453    tmp = find_home_of_exe("pico");
     1454    if (tmp) {
    14431455        strcpy(output, "pico");
    1444     } else if (find_home_of_exe("nano")) {
    1445         strcpy(output, "nano");
    1446     } else if (find_home_of_exe("e3em")) {
    1447         strcpy(output, "e3em");
    1448     } else if (find_home_of_exe("e3vi")) {
    1449         strcpy(output, "e3vi");
    1450     } else {
    1451         strcpy(output, "vi");
    1452     }
    1453     if (!find_home_of_exe(output)) {
     1456    } else {
     1457        mr_free(tmp);
     1458        tmp = find_home_of_exe("nano");
     1459        if (tmp) {
     1460            strcpy(output, "nano");
     1461        } else {
     1462            mr_free(tmp);
     1463            tmp = find_home_of_exe("joe");
     1464            if (tmp) {
     1465                strcpy(output, "joe");
     1466            } else {
     1467                strcpy(output, "vi");
     1468            }
     1469        }
     1470    }
     1471    mr_free(tmp);
     1472
     1473    tmp = find_home_of_exe(output);
     1474    if (!tmp) {
    14541475        log_msg(2, " (find_my_editor) --- warning - %s not found", output);
    14551476    }
     1477    mr_free(tmp);
    14561478    return (output);
    14571479}
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2329 r2331  
    25352535    log_msg(1, "path is now %s", newpath);
    25362536    log_msg(1, "restoring everything");
    2537     if (!find_home_of_exe("petris") && !g_text_mode) {
     2537    tmp = find_home_of_exe("petris");
     2538    if (!tmp && !g_text_mode) {
    25382539        newtDrawRootText(0, g_noof_rows - 2,
    25392540                         "Press ALT-<left cursor> twice to play Petris :-) ");
    25402541        newtRefresh();
    25412542    }
     2543    mr_free(tmp);
     2544
    25422545    mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives");
    25432546    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
Note: See TracChangeset for help on using the changeset viewer.