Ignore:
Timestamp:
Jul 17, 2006, 3:44:46 PM (18 years ago)
Author:
bcornec
Message:

Huge memory management patch.
Still not finished but a lot as been done.
What remains is around some functions returning strings, and some structure members.
(Could not finish due to laptop failure !)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c

    r524 r688  
    11/***************************************************************************
    2        mondo-compare.c  -  compares mondoarchive data
    3                              -------------------
    4     begin                : Fri Apr 25 2003
    5     copyright            : (C) 2000 by Hugo Rabson
    6     email                : Hugo Rabson <hugorabson@msn.com>
    7     cvsid                : $Id$
    8 ***************************************************************************/
    9 
    10 /***************************************************************************
    11  *                                                                         *
    12  *   This program is free software; you can redistribute it and/or modify  *
    13  *   it under the terms of the GNU General Public License as published by  *
    14  *   the Free Software Foundation; either version 2 of the License, or     *
    15  *   (at your option) any later version.                                   *
    16  *                                                                         *
    17  ***************************************************************************/
    18 
    19 /***************************************************************************
    20  *                         Change Log                                      *
    21  ***************************************************************************
    22 .
    23 
    24 
    25 
    26 10/21/2003
    27 - changed "/mnt/cdrom" to MNT_CDROM
    28 
    29 10/18
    30 - don't say unknown compressor if no compressor at all
    31 
    32 09/17
    33 - cleaned up logging & conversion-to-changed.txt
    34 - cleaned up compare_mode()
    35 
    36 09/16
    37 - fixed bad malloc(),free() pairs in compare_a_biggiefile()
    38 
    39 09/14
    40 - compare_mode() --- a couple of strings were the wrong way round,
    41   e.g. changed.txt and changed.files
    42 
    43 05/05
    44 - exclude /dev/ * from list of changed files
    45 
    46 04/30
    47 - added textonly mode
    48 
    49 04/27
    50 - improved compare_mode() to allow for ISO/cd/crazy people
    51 
    52 04/25
    53 - first incarnation
    54 */
     2 * $Id$ - compares mondoarchive data
     3**/
    554
    565
     
    587#include "../common/mondostructures.h"
    598#include "../common/libmondo.h"
    60 //#include "../../config.h"
    619#include "mr-externs.h"
    6210#include "mondo-rstr-compare.h"
     
    6715#endif
    6816
    69 //static char cvsid[] = "$Id$";
    70 
    7117void popup_changelist_from_file(char *);
    7218
     
    8935
    9036  /** needs malloc *******/
    91     char *checksum_ptr;
    92     char *original_cksum_ptr;
    93     char *bigfile_fname_ptr;
    94     char *tmp_ptr;
    95     char *command_ptr;
    96 
    97     char *checksum, *original_cksum, *bigfile_fname, *tmp, *command;
    98 
    99     char *p;
    100     int i;
     37    char *checksum = NULL;
     38    char *original_cksum = NULL;
     39    char *bigfile_fname = NULL;
     40    char *tmp = NULL;
     41    char *tmp1 = NULL;
     42    char *command = NULL;
     43
     44    char *p = NULL;
     45    int i = 0;
     46    int n = 0;
    10147    int retval = 0;
    10248
    10349    struct s_filename_and_lstat_info biggiestruct;
    10450
    105     malloc_string(checksum);
    106     malloc_string(original_cksum);
    107     malloc_string(bigfile_fname);
    108     malloc_string(tmp);
    109     malloc_string(command);
    110     malloc_string(checksum_ptr);
    111     malloc_string(original_cksum_ptr);
    112     malloc_string(bigfile_fname_ptr);
    113     malloc_string(command_ptr);
    114     malloc_string(tmp_ptr);
    115 
    116   /*********************************************************************
    117    * allocate memory clear test                sab 16 feb 2003         *
    118    *********************************************************************/
    11951    assert(bkpinfo != NULL);
    120     memset(checksum_ptr, '\0', sizeof(checksum));
    121     memset(original_cksum_ptr, '\0', sizeof(original_cksum));
    122     memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));
    123     memset(tmp_ptr, '\0', sizeof(tmp));
    124     memset(command_ptr, '\0', sizeof(command));
    125   /** end **/
    126 
    127     if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
     52
     53    tmp1 = slice_fname(bigfileno, 0, ARCHIVES_PATH, "");
     54    if (!does_file_exist(tmp1)) {
    12855        if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
    12956            insist_on_this_cd_number(bkpinfo, (++g_current_media_number));
    13057        } else {
    131             sprintf(tmp_ptr,
    132                     "No CD's left. No biggiefiles left. No prob, Bob.");
    133             log_msg(2, tmp_ptr);
     58            log_msg(2, "No CD's left. No biggiefiles left. No problem.");
    13459            return (0);
    13560        }
    13661    }
    137     if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
    138         sprintf(tmp_ptr,
    139                 _("Cannot open bigfile %ld (%s)'s info file"),
    140                 bigfileno + 1, bigfile_fname_ptr);
    141         log_to_screen(tmp_ptr);
     62    if (!(fin = fopen(tmp1, "r"))) {
     63        asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"),
     64                bigfileno + 1, tmp);
     65        log_to_screen(tmp);
     66        paranoid_free(tmp);
     67        paranoid_free(tmp1);
    14268        return (1);
    14369    }
     
    14571    paranoid_fclose(fin);
    14672
    147     strcpy(checksum_ptr, biggiestruct.checksum);
    148     strcpy(bigfile_fname_ptr, biggiestruct.filename);
    149 
    150     log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename);
    151     log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum);
    152 
    153     sprintf(tmp_ptr, _("Comparing %s"), bigfile_fname_ptr);
     73    asprintf(&checksum, biggiestruct.checksum);
     74    asprintf(&bigfile_fname, biggiestruct.filename);
     75
     76    log_msg(2, "biggiestruct.filename = %s", bigfile_fname);
     77    log_msg(2, "biggiestruct.checksum = %s", checksum);
    15478
    15579    if (!g_text_mode) {
    156         newtDrawRootText(0, 22, tmp_ptr);
     80        asprintf(&tmp, _("Comparing %s"), bigfile_fname);
     81        newtDrawRootText(0, 22, tmp);
    15782        newtRefresh();
    158     }
     83        paranoid_free(tmp);
     84    }
     85    /* BERLIOS: Useless ?
    15986    if (!checksum[0]) {
    16087        log_msg(2, "Warning - %s has no checksum", bigfile_fname_ptr);
    161     }
    162     if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
    163         strcpy(original_cksum_ptr, "IGNORE");
    164     } else {
    165         sprintf(command_ptr,
     88    } */
     89    if (!strncmp(bigfile_fname, "/dev/", 5)) {
     90        log_msg(2, _("Ignoring device %s"), bigfile_fname);
     91        return(0);
     92    } else {
     93        asprintf(&command,
    16694                "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors.txt",
    167                 MNT_RESTORING, bigfile_fname_ptr);
    168     }
    169     log_msg(2, command_ptr);
    170     paranoid_system
    171         ("cat /tmp/errors >> /tmp/mondo-restore.log 2> /dev/null");
    172     if (system(command_ptr)) {
     95                MNT_RESTORING, bigfile_fname);
     96    }
     97    log_msg(2, command);
     98    paranoid_system("cat /tmp/errors >> /tmp/mondo-restore.log 2> /dev/null");
     99    if (system(command)) {
    173100        log_OS_error("Warning - command failed");
    174         original_cksum[0] = '\0';
     101        paranoid_free(command);
     102        paranoid_free(bigfile_fname);
    175103        return (1);
    176104    } else {
     105        paranoid_free(command);
    177106        if (!(fin = fopen("/tmp/md5sum.txt", "r"))) {
    178             log_msg(2,
    179                     "Unable to open /tmp/md5sum.txt; can't get live checksum");
    180             original_cksum[0] = '\0';
     107            log_msg(2, "Unable to open /tmp/md5sum.txt; can't get live checksum");
     108            paranoid_free(bigfile_fname);
    181109            return (1);
    182110        } else {
    183             fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin);
     111            getline(&original_cksum, &n, fin);
    184112            paranoid_fclose(fin);
    185             for (i = strlen(original_cksum_ptr);
     113            for (i = strlen(original_cksum);
    186114                 i > 0 && original_cksum[i - 1] < 32; i--);
    187115            original_cksum[i] = '\0';
    188             p = (char *) strchr(original_cksum_ptr, ' ');
     116            p = (char *) strchr(original_cksum, ' ');
    189117            if (p) {
    190118                *p = '\0';
     
    192120        }
    193121    }
    194     sprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1,
    195             bigfile_fname_ptr);
    196     if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) {
    197         strcat(tmp_ptr, " ... OK");
    198     } else {
    199         strcat(tmp_ptr, "... changed");
     122    if (!strcmp(checksum, original_cksum) != 0) {
     123        log_msg(1, "bigfile #%ld ('%s') ... OK", bigfileno + 1, bigfile_fname);
     124    } else {
     125        log_msg(1, "bigfile #%ld ('%s') ... changed", bigfileno + 1, bigfile_fname);
    200126        retval++;
    201127    }
    202     log_msg(1, tmp_ptr);
     128    paranoid_free(original_cksum);
     129    paranoid_free(checksum);
     130
    203131    if (retval) {
    204132        if (!(fout = fopen("/tmp/changed.txt", "a"))) {
    205133            fatal_error("Cannot openout changed.txt");
    206134        }
    207         fprintf(fout, "%s\n", bigfile_fname_ptr);
     135        fprintf(fout, "%s\n", bigfile_fname);
    208136        paranoid_fclose(fout);
    209137    }
    210 
    211     paranoid_free(original_cksum_ptr);
    212     paranoid_free(original_cksum);
    213     paranoid_free(bigfile_fname_ptr);
    214138    paranoid_free(bigfile_fname);
    215     paranoid_free(checksum_ptr);
    216     paranoid_free(checksum);
    217     paranoid_free(command_ptr);
    218     paranoid_free(command);
    219     paranoid_free(tmp_ptr);
    220     paranoid_free(tmp);
    221139
    222140    return (retval);
     
    238156    int res;
    239157    long noof_biggiefiles, bigfileno = 0;
    240     char tmp[MAX_STR_LEN];
     158    char *tmp;
    241159
    242160    assert(bkpinfo != NULL);
     
    254172    }
    255173    mvaddstr_and_log_it(g_currentY, 0,
    256                         _("Comparing large files                                                  "));
     174                        _
     175                        ("Comparing large files                                                  "));
    257176    open_progress_form(_("Comparing large files"),
    258177                       _("I am now comparing the large files"),
     
    260179                       noof_biggiefiles);
    261180    for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) {
    262         sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);
     181        asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);
    263182        log_msg(1, tmp);
    264183        update_progress_form(tmp);
     184        paranoid_free(tmp);
    265185        res = compare_a_biggiefile(bkpinfo, bigfileno);
    266186        retval += res;
     
    268188    }
    269189    close_progress_form();
     190    /* BERLIOS: useless ?
    270191    return (0);
     192    */
    271193    if (retval) {
    272194        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
     
    299221
    300222  /***  needs malloc *********/
    301     char *command, *tmp, *filelist_name, *logfile, *archiver_exe,
    302         *compressor_exe;
    303 
    304     malloc_string(command);
    305     malloc_string(tmp);
    306     malloc_string(filelist_name);
    307     malloc_string(logfile);
    308     malloc_string(archiver_exe);
    309     malloc_string(compressor_exe);
     223    char *command = NULL;
     224    char *tmp = NULL;
     225    char *filelist_name = NULL;
     226    char *logfile = NULL;
     227    char *archiver_exe = NULL;
     228    char *compressor_exe = NULL;
    310229
    311230    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    312231    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    313     sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number);
    314     sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d",
     232    asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d",
    315233            current_tarball_number);
    316234
    317235    noof_lines = count_lines_in_file(filelist_name);
     236    paranoid_free(filelist_name);
    318237
    319238    if (strstr(tarball_fname, ".bz2")) {
    320         strcpy(compressor_exe, "bzip2");
     239        asprintf(&compressor_exe, "bzip2");
    321240    } else if (strstr(tarball_fname, ".lzo")) {
    322         strcpy(compressor_exe, "lzop");
    323     } else {
    324         compressor_exe[0] = '\0';
     241        asprintf(&compressor_exe, "lzop");
     242    } else {
     243        compressor_exe = NULL;
    325244    }
    326245
    327246    if (use_star) {
    328         strcpy(archiver_exe, "star");
    329     } else {
    330         strcpy(archiver_exe, "afio");
    331     }
    332 
    333     if (compressor_exe[0]) {
    334         strcpy(tmp, compressor_exe);
    335         if (!find_home_of_exe(tmp)) {
     247        asprintf(&archiver_exe, "star -bz");
     248    } else {
     249        asprintf(&archiver_exe, "afio");
     250    }
     251
     252    if (compressor_exe != NULL) {
     253        if (!find_home_of_exe(compressor_exe)) {
    336254            fatal_error("(compare_a_tarball) Compression program missing");
    337255        }
    338         if (use_star)           // star
    339         {
    340             if (!strcmp(compressor_exe, "bzip2")) {
    341                 strcat(archiver_exe, " -bz");
    342             } else {
     256        if (use_star) {
     257            if (strcmp(compressor_exe, "bzip2")) {
    343258                fatal_error
    344259                    ("(compare_a_tarball) Please use only bzip2 with star");
    345260            }
    346         } else                  // afio
    347         {
     261        } else {
     262            asprintf(&tmp, compressor_exe);
    348263            sprintf(compressor_exe, "-P %s -Z", tmp);
     264            paranoid_free(tmp);
    349265        }
    350266    }
     
    356272#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
    357273#endif
     274
     275    asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);
    358276    if (use_star)               // doesn't use compressor_exe
    359277    {
    360         sprintf(command,
     278        asprintf(&command,
    361279                "%s -diff H=star file=%s >> %s 2>> %s",
    362280                archiver_exe, tarball_fname, logfile, logfile);
    363281    } else {
    364         sprintf(command,
     282        asprintf(&command,
    365283                "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s",
    366284                archiver_exe,
     
    369287    }
    370288#undef BUFSIZE
     289    paranoid_free(archiver_exe);
     290    paranoid_free(compressor_exe);
    371291
    372292    res = system(command);
     
    374294    if (res) {
    375295        log_OS_error(command);
    376         sprintf(tmp, "Warning - afio returned error = %d", res);
    377296    }
    378297    if (length_of_file(logfile) > 5) {
     
    385304        archiver_errors = 0;
    386305    }
    387     sprintf(tmp, "%ld difference%c in fileset #%d          ",
    388             archiver_errors, (archiver_errors != 1) ? 's' : ' ',
    389             current_tarball_number);
     306    paranoid_free(command);
     307
    390308    if (archiver_errors) {
    391         sprintf(tmp,
     309        asprintf(&tmp,
    392310                "Differences found while processing fileset #%d       ",
    393311                current_tarball_number);
    394312        log_msg(1, tmp);
     313        paranoid_free(tmp);
    395314    }
    396315    unlink(logfile);
    397     paranoid_free(command);
    398     paranoid_free(tmp);
    399     paranoid_free(filelist_name);
    400316    paranoid_free(logfile);
    401     malloc_string(archiver_exe);
    402     malloc_string(compressor_exe);
    403317    return (retval);
    404318}
     
    422336  /**  needs malloc **********/
    423337
    424     char *tarball_fname, *progress_str, *tmp;
     338    char *tarball_fname = NULL;
     339    char *progress_str = NULL;
     340    char *tmp = NULL;
    425341    long max_val;
    426 
    427     malloc_string(tarball_fname);
    428     malloc_string(progress_str);
    429     malloc_string(tmp);
    430342
    431343    assert(bkpinfo != NULL);
     
    434346
    435347    max_val = atol(tmp);
    436     sprintf(progress_str, _("Comparing with %s #%d "),
     348    paranoid_free(tmp);
     349
     350    asprintf(&progress_str, _("Comparing with %s #%d "),
    437351            media_descriptor_string(bkpinfo->backup_media_type),
    438352            g_current_media_number);
     
    448362        insist_on_this_cd_number(bkpinfo, g_current_media_number);
    449363        update_progress_form(progress_str);
    450         sprintf(tarball_fname,
     364        asprintf(&tarball_fname,
    451365                MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
    452366
    453367        if (!does_file_exist(tarball_fname)) {
    454             sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
     368            paranoid_free(tarball_fname);
     369            asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
    455370                    current_tarball_number);
    456371        }
    457372        if (!does_file_exist(tarball_fname)) {
    458             sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",
     373            paranoid_free(tarball_fname);
     374            asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.",
    459375                    current_tarball_number);
    460376        }
    461377        if (!does_file_exist(tarball_fname)) {
    462             sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
     378            paranoid_free(tarball_fname);
     379            asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
    463380                    current_tarball_number);
    464381        }
    465382        if (!does_file_exist(tarball_fname)) {
    466             sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",
     383            paranoid_free(tarball_fname);
     384            asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.",
    467385                    current_tarball_number);
    468386        }
     
    473391                == 0) {
    474392                log_msg(2, "OK, I think I'm done with tarballs...");
     393                paranoid_free(tarball_fname);
    475394                break;
    476395            }
    477396            log_msg(2, "OK, I think it's time for another CD...");
    478397            g_current_media_number++;
    479             sprintf(progress_str, _("Comparing with %s #%d "),
     398            paranoid_free(progress_str);
     399            asprintf(&progress_str, _("Comparing with %s #%d "),
    480400                    media_descriptor_string(bkpinfo->backup_media_type),
    481401                    g_current_media_number);
     
    483403        } else {
    484404            res = compare_a_tarball(tarball_fname, current_tarball_number);
     405            paranoid_free(tarball_fname);
    485406
    486407            g_current_progress++;
     
    488409        }
    489410    }
     411    paranoid_free(progress_str);
    490412    close_progress_form();
     413
    491414    if (retval) {
    492415        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
     
    494417        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    495418    }
    496     paranoid_free(tarball_fname);
    497     paranoid_free(progress_str);
    498     paranoid_free(tmp);
    499419    return (retval);
    500420}
     
    519439{
    520440  /** needs malloc *********/
    521     char *tmp, *cwd, *new, *command;
     441    char *tmp = NULL;
     442    char *cwd = NULL;
     443    char *new = NULL;
     444    char *command = NULL;
    522445    int resA = 0;
    523446    int resB = 0;
    524447    long noof_changed_files;
    525448
    526     malloc_string(tmp);
    527449    malloc_string(cwd);
    528450    malloc_string(new);
    529     malloc_string(command);
    530451
    531452    assert(bkpinfo != NULL);
     
    534455    chdir(bkpinfo->restore_path);
    535456    getcwd(new, MAX_STR_LEN - 1);
    536     sprintf(tmp, "new path is %s", new);
    537457    insist_on_this_cd_number(bkpinfo, g_current_media_number);
    538458    unlink("/tmp/changed.txt");
     
    543463    noof_changed_files = count_lines_in_file("/tmp/changed.txt");
    544464    if (noof_changed_files) {
    545         sprintf(tmp, _("%ld files do not match the backup            "),
     465        asprintf(&tmp, _("%ld files do not match the backup            "),
    546466                noof_changed_files);
    547467        //      mvaddstr_and_log_it( g_currentY++, 0, tmp );
    548468        log_to_screen(tmp);
    549         sprintf(command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
     469        paranoid_free(tmp);
     470
     471        asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
    550472        paranoid_system(command);
    551     } else {
    552         sprintf(tmp, _("All files match the backup                     "));
     473        paranoid_free(command);
     474    } else {
     475        asprintf(&tmp, _("All files match the backup                     "));
    553476        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    554477        log_to_screen(tmp);
    555     }
    556 
    557     paranoid_free(tmp);
     478        paranoid_free(tmp);
     479    }
     480
    558481    paranoid_free(cwd);
    559482    paranoid_free(new);
    560     paranoid_free(command);
    561483
    562484    return (resA + resB);
     
    566488 *END_COMPARE_TO_CD                                                       *
    567489 **************************************************************************/
    568 
    569 
    570490
    571491
     
    588508    char *tmp;
    589509
    590     malloc_string(tmp);
    591 
    592510  /**************************************************************************
    593511   * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to     *
     
    600518    while (get_cfg_file_from_archive(bkpinfo)) {
    601519        if (!ask_me_yes_or_no
    602             (_("Failed to find config file/archives. Choose another source?")))
     520            (_
     521             ("Failed to find config file/archives. Choose another source?")))
    603522        {
    604523            fatal_error("Unable to find config file/archives. Aborting.");
     
    628547        mvaddstr_and_log_it(g_currentY++,
    629548                            0,
    630                             _("Warning - differences found during the compare phase"));
     549                            _
     550                            ("Warning - differences found during the compare phase"));
    631551    }
    632552
     
    635555    if (count_lines_in_file("/tmp/changed.txt") > 0) {
    636556        mvaddstr_and_log_it(g_currentY++, 0,
    637                             _("Differences found while files were being compared."));
     557                            _
     558                            ("Differences found while files were being compared."));
    638559        streamline_changes_file("/tmp/changed.files", "/tmp/changed.txt");
    639560        if (count_lines_in_file("/tmp/changed.files") <= 0) {
    640561            mvaddstr_and_log_it(g_currentY++, 0,
    641                                 _("...but they were logfiles and temporary files. Your archives are fine."));
    642             log_to_screen
    643                 (_("The differences were logfiles and temporary files. Your archives are fine."));
     562                                _
     563                                ("...but they were logfiles and temporary files. Your archives are fine."));
     564            log_to_screen(_
     565                          ("The differences were logfiles and temporary files. Your archives are fine."));
    644566        } else {
    645567            q = count_lines_in_file("/tmp/changed.files");
    646             sprintf(tmp, _("%ld significant difference%s found."), q,
     568            asprintf(&tmp, _("%ld significant difference%s found."), q,
    647569                    (q != 1) ? "s" : "");
    648570            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    649571            log_to_screen(tmp);
    650 
    651             strcpy(tmp,
     572            paranoid_free(tmp);
     573
     574            asprintf(&tmp,
    652575                   _("Type 'less /tmp/changed.files' for a list of non-matching files"));
    653576            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    654577            log_to_screen(tmp);
     578            paranoid_free(tmp);
    655579
    656580            log_msg(2, "calling popup_changelist_from_file()");
     
    660584    } else {
    661585        log_to_screen
    662             (_("No significant differences were found. Your backup is perfect."));
     586            (_
     587             ("No significant differences were found. Your backup is perfect."));
    663588    }
    664589    kill_petris();
    665     paranoid_free(tmp);
    666590    return (retval);
    667591}
     
    670594 *END_COMPARE_MODE                                                        *
    671595 **************************************************************************/
     596
    672597
    673598/**
     
    683608    int res;
    684609
     610    char *dir = NULL;
     611    char *command = NULL;
     612
     613    assert(bkpinfo != NULL);
    685614  /** needs malloc **/
    686     char *dir, *command, *tmp;
    687 
    688     assert(bkpinfo != NULL);
    689615    malloc_string(dir);
    690     malloc_string(command);
    691616    getcwd(dir, MAX_STR_LEN);
    692617    chdir(bkpinfo->restore_path);
    693618
    694     sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
     619    asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    695620            bkpinfo->restore_path);
    696621    run_program_and_log_output(command, FALSE);
     622    paranoid_free(command);
    697623    mvaddstr_and_log_it(g_currentY,
    698624                        0, _("Verifying archives against filesystem"));
     
    700626    if (bkpinfo->disaster_recovery
    701627        && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    702         asprintf(&tmp,
    703                last_line_of_file("/tmp/CDROM-LIVES-HERE"));
    704628        paranoid_free(bkpinfo->media_device);
    705         bkpinfo->media_device = tmp;
     629        // last_line_of_file allocates the string
     630        bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
    706631    } else {
    707632        paranoid_free(bkpinfo->media_device);
     633        // find_cdrom_device allocates the string
    708634        bkpinfo->media_device = find_cdrom_device(FALSE);
    709635    }
     
    721647    mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    722648    paranoid_free(dir);
    723     paranoid_free(command);
    724649    return (res);
    725650}
     
    744669{
    745670    int res;
    746     char *dir, *command;
     671    char *dir = NULL;
     672    char *command = NULL;
    747673
    748674    assert(bkpinfo != NULL);
    749675    malloc_string(dir);
    750     malloc_string(command);
    751676
    752677    getcwd(dir, MAX_STR_LEN);
    753678    chdir(bkpinfo->restore_path);
    754     sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
     679    asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    755680            bkpinfo->restore_path);
    756681    run_program_and_log_output(command, FALSE);
     682    paranoid_free(command);
     683
    757684    mvaddstr_and_log_it(g_currentY,
    758685                        0, _("Verifying archives against filesystem"));
     
    765692    }
    766693    paranoid_free(dir);
    767     paranoid_free(command);
    768694    return (res);
    769695}
Note: See TracChangeset for help on using the changeset viewer.