Changeset 2276


Ignore:
Timestamp:
Jul 13, 2009, 2:34:36 AM (10 years ago)
Author:
bruno
Message:

r3262@localhost: bruno | 2009-07-13 02:18:17 +0200
Replace sprintf by mr_asprintf in libmondo-verify.c

File:
1 edited

Legend:

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

    r2242 r2276  
    8080{
    8181    /*@ buffer ********************************************************** */
    82     char *command;
    83     char *afio_found_changes;
     82    char *command = NULL;
     83    char *afio_found_changes = NULL;
    8484
    8585    /*@ int ************************************************************* */
     
    8989    long afio_diffs = 0;
    9090
    91     command = malloc(2000);
    92     afio_found_changes = malloc(500);
    9391    assert_string_is_neither_NULL_nor_zerolength(changedfiles_fname);
    9492    assert_string_is_neither_NULL_nor_zerolength(ignorefiles_fname);
    9593    assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
    9694
    97     sprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
     95    mr_asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
    9896    paranoid_system("sync");
    9997
    100 /*  sprintf (command,
    101        "grep \"afio: \" %s | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort -u | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
    102        stderr_fname, afio_found_changes);
    103 */
    104 
    10598    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    106     sprintf(command,
    107             "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s",
    108             stderr_fname, afio_found_changes);
     99    mr_asprintf(&command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
    109100    log_msg(2, command);
    110101    res = system(command);
     102    mr_free(command);
     103
    111104    if (res) {
    112105        log_msg(2, "Warning - failed to think");
     
    114107
    115108    log_msg(1, "Now scanning log file for 'star: ' stuff");
    116     sprintf(command,
     109    mr_asprintf(&command,
    117110            "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s",
    118111            stderr_fname, afio_found_changes);
    119112    log_msg(2, command);
    120113    res = system(command);
     114    mr_free(command);
     115
    121116    if (res) {
    122117        log_msg(2, "Warning - failed to think");
    123118    }
    124 //  exclude_nonexistent_files (afio_found_changes);
    125119    afio_diffs = count_lines_in_file(afio_found_changes);
    126     sprintf(command,
     120    mr_asprintf(&command,
    127121            "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    128122            ignorefiles_fname, afio_found_changes, afio_found_changes,
    129123            changedfiles_fname);
     124    mr_free(afio_found_changes);
    130125    log_msg(2, command);
    131126    paranoid_system(command);
    132     paranoid_free(command);
    133     paranoid_free(afio_found_changes);
     127    mr_free(command);
    134128    return (afio_diffs);
    135129}
     
    151145
    152146    /*@ buffers ********************************************************* */
    153     char *tmp;
     147    char *tmp = NULL;
    154148    char *mds = NULL;
    155149
     
    162156    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    163157    assert(bkpinfo != NULL);
    164     malloc_string(tmp);
    165158
    166159    for (set_number = 0;
     
    179172        } else {
    180173            retval++;
    181             sprintf(tmp, "Warning - missing set(s) between %d and %d\n",
     174            mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",
    182175                    g_last_afioball_number, set_number - 1);
    183176            log_to_screen(tmp);
     177            mr_free(tmp);
    184178        }
    185179    }
    186180    mds = media_descriptor_string(bkpinfo->backup_media_type);
    187     sprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
     181    mr_asprintf(&tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
    188182    mr_free(mds);
    189183
    190184    open_evalcall_form(tmp);
     185    mr_free(tmp);
    191186
    192187    for (total_sets = set_number;
     
    208203    g_last_afioball_number = set_number - 1;
    209204    close_evalcall_form();
    210     paranoid_free(tmp);
    211205    return (retval);
    212206}
     
    227221
    228222    /*@ buffer ********************************************************** */
    229     char *tmp;
    230     char *mountpoint;
    231 //  char ca, cb;
    232     char *command;
     223    char *tmp = NULL;
     224    char *mountpoint = NULL;
     225    char *command = NULL;
    233226    char *mds = NULL;
    234227    char *sz_exe;
     
    252245    FILE *fin;
    253246    int retval = 0;
    254 //  long long outlen;
    255 
    256     malloc_string(tmp);
    257     malloc_string(mountpoint);
    258     malloc_string(command);
     247
    259248    malloc_string(sz_exe);
    260249    if (!bufblkA) {
     
    286275    log_it("before vsbf");
    287276    mds = media_descriptor_string(bkpinfo->backup_media_type);
    288     sprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
     277    mr_asprintf(&tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
    289278    mr_free(mds);
    290279
    291280    open_evalcall_form(tmp);
     281    mr_free(tmp);
     282
    292283    log_it("after vsbf");
    293     sprintf(mountpoint, "%s/archives", mtpt);
     284    mr_asprintf(&mountpoint, "%s/archives", mtpt);
    294285    if (last_bigfile_num == -1) {
    295286        bigfile_num = 0;
     
    302293        slice_num = last_slice_num + 1;
    303294    }
    304     while (does_file_exist
    305            (slice_fname
    306             (bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
     295    while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
    307296           ||
    308            does_file_exist(slice_fname
    309                            (bigfile_num, slice_num, mountpoint, ""))) {
     297           does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
    310298        // handle slices until end of CD
    311299        if (slice_num == 0) {
    312300            log_msg(2, "ISO=%d  bigfile=%ld --START--",
    313301                    g_current_media_number, bigfile_num);
    314             if (!
    315                 (fin =
    316                  fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""),
    317                        "r"))) {
     302            if (! (fin = fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), "r"))) {
    318303                log_msg(2, "Cannot open bigfile's info file");
    319304            } else {
    320                 if (fread
    321                     ((void *) &biggiestruct, 1, sizeof(biggiestruct),
    322                      fin) < sizeof(biggiestruct)) {
     305                if (fread ((void *) &biggiestruct, 1, sizeof(biggiestruct), fin) < sizeof(biggiestruct)) {
    323306                    log_msg(2, "Unable to get biggiestruct");
    324307                }
    325308                paranoid_fclose(fin);
    326309            }
    327             sprintf(tmp, "%s/%s", bkpinfo->restore_path,
    328                     biggiestruct.filename);
     310            mr_asprintf(&tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    329311            log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    330             if (!(forig = fopen(tmp, "r"))) {
     312            forig = fopen(tmp, "r");
     313            mr_free(tmp);
     314
     315            if (!forig) {
    331316                log_msg(2, "Failed to open bigfile. Darn.");
    332317                log_to_screen("%s/%s not found on live filesystem",
     
    338323                            bkpinfo->tmpdir);
    339324                system(tmp);
    340                 paranoid_free(tmp);
     325                mr_free(tmp);
    341326
    342327                bigfile_num++;
     
    357342                    g_current_media_number, bigfile_num, slice_num);
    358343            if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
    359                 sprintf(command, "%s -dc %s 2>> %s",
     344                mr_asprintf(&command, "%s -dc %s 2>> %s",
    360345                        sz_exe,
    361346                        slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix),
    362347                        MONDO_LOGFILE);
    363348            } else {
    364                 sprintf(command, "cat %s 2>> %s",
    365                         slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
     349                mr_asprintf(&command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
    366350            }
    367             if ((pin = popen(command, "r"))) {
     351            pin = popen(command, "r");
     352            mr_free(command);
     353            if (pin) {
    368354                res = 0;
    369355                while (!feof(pin)) {
     
    404390        }
    405391    }
     392    mr_free(mountpoint);
    406393    last_bigfile_num = bigfile_num;
    407394    last_slice_num = slice_num - 1;
     
    416403        paranoid_free(bufblkB);
    417404    }
    418     paranoid_free(tmp);
    419     paranoid_free(command);
    420405    paranoid_free(sz_exe);
    421     paranoid_free(mountpoint);
    422406    return (0);
    423407}
     
    442426{
    443427    /*@ buffers ********************************************************* */
    444     char *command;
    445     char *outlog;
     428    char *command = NULL;
     429    char *outlog = NULL;
    446430    char *tmp;
    447431    //  char *p;
     
    455439
    456440
    457     command = malloc(2000);
    458     malloc_string(outlog);
    459441    malloc_string(tmp);
    460442    assert(bkpinfo != NULL);
     
    462444
    463445    log_it("Verifying fileset '%s'", tarball_fname);
    464     /*  chdir("/"); */
    465     sprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
    466 /* if programmer forgot to say which compression thingy to use then find out */
     446    mr_asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);
     447    /* if programmer forgot to say which compression thingy to use then find out */
    467448    if (strstr(tarball_fname, ".lzo")
    468449        && strcmp(bkpinfo->zip_suffix, "lzo")) {
     
    493474        bkpinfo->use_star = TRUE;
    494475        if (strstr(tarball_fname, ".bz2"))
    495             sprintf(command,
     476            mr_asprintf(&command,
    496477                    "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
    497478                    tarball_fname,
     
    500481    } else {
    501482        bkpinfo->use_star = FALSE;
    502         sprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s",
     483        mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",
    503484                bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    504485    }
    505486    log_msg(6, "command=%s", command);
    506487    paranoid_system(command);
     488    mr_free(command);
     489
    507490    if (length_of_file(outlog) < 10) {
    508         sprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
     491        mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    509492    } else {
    510         sprintf(command, "cut -d: -f%d %s | sort -u",
     493        mr_asprintf(&command, "cut -d: -f%d %s | sort -u",
    511494                (bkpinfo->use_star) ? 1 : 2, outlog);
    512495        pin = popen(command, "r");
     
    544527        }
    545528    }
    546     /*  chdir(old_pwd); */
    547     //  sprintf (tmp, "uniq -u %s >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
    548     //  paranoid_system (tmp);
    549     //  unlink ("/tmp/mondo-verify.err");
    550     paranoid_free(command);
    551     paranoid_free(outlog);
     529    mr_free(command);
     530    mr_free(outlog);
    552531    paranoid_free(tmp);
    553532    return (0);
     
    604583
    605584    /*@ buffers ********************************************************** */
    606     char *tmp;
    607     char *tarball_fname;
     585    char *tmp = NULL;
     586    char *tarball_fname = NULL;
    608587
    609588    /*@ pointers ********************************************************* */
    610589    char *p;
    611590
    612     malloc_string(tmp);
    613     malloc_string(tarball_fname);
    614591    assert(bkpinfo != NULL);
    615592    assert_string_is_neither_NULL_nor_zerolength(orig_fname);
     
    621598        p++;
    622599    }
    623     sprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     600    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    624601    paranoid_system(tmp);
    625     sprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    626     sprintf(tmp, "Temporarily copying file from tape to '%s'",
    627             tarball_fname);
    628 /*  log_it(tmp); */
     602    mr_free(tmp);
     603
     604    mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    629605    read_file_from_stream_to_file(tarball_fname, size);
    630606    res = verify_a_tarball(tarball_fname);
    631607    if (res) {
    632         sprintf(tmp,
    633                 "Afioball '%s' no longer matches your live filesystem", p);
    634         log_msg(0, tmp);
     608        log_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
    635609        retval++;
    636610    }
    637611    unlink(tarball_fname);
    638     paranoid_free(tmp);
    639     paranoid_free(tarball_fname);
     612    mr_free(tarball_fname);
    640613    return (retval);
    641614}
     
    660633
    661634    /*@ char ************************************************************ */
    662     char *test_file;
     635    char *test_file = NULL;
    663636    char *biggie_cksum;
    664637    char *orig_cksum;
    665     char *tmp;
     638    char *tmp = NULL;
    666639    char *slice_fnam;
    667640
     
    672645    long long slice_siz;
    673646
    674     malloc_string(test_file);
    675647    malloc_string(biggie_cksum);
    676648    malloc_string(orig_cksum);
    677     malloc_string(tmp);
    678649    malloc_string(slice_fnam);
    679650    assert(bkpinfo != NULL);
     
    686657        p++;
    687658    }
    688     sprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    689     sprintf(tmp,
    690             "Temporarily copying biggiefile %s's slices from tape to '%s'",
    691             p, test_file);
    692 /*  log_it(tmp); */
     659    mr_asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    693660    for (res =
    694661         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
     
    716683        strcpy(orig_cksum, calc_checksum_of_file(biggie_fname));
    717684        if (strcmp(biggie_cksum, orig_cksum)) {
    718             sprintf(tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
    719                     orig_cksum);
    720             log_msg(2, tmp);
    721             sprintf(tmp, "%s has changed on live filesystem",
    722                     biggie_fname);
     685            log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
     686            mr_asprintf(&tmp, "%s has changed on live filesystem", biggie_fname);
    723687            log_to_screen(tmp);
    724             sprintf(tmp, "echo \"%s\" >> %s/biggies.changed",
    725                     biggie_fname, bkpinfo->tmpdir);
     688            mr_free(tmp);
     689
     690            mr_asprintf(&tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
    726691            system(tmp);
    727         }
    728     }
    729     paranoid_free(test_file);
     692            mr_free(tmp);
     693        }
     694    }
     695    mr_free(test_file);
    730696    paranoid_free(biggie_cksum);
    731697    paranoid_free(orig_cksum);
    732     paranoid_free(tmp);
    733698    paranoid_free(slice_fnam);
    734699    return (retval);
     
    754719
    755720    /*@ buffers ***************************************************** */
    756     char *tmp;
     721    char *tmp = NULL;
    757722    char *fname;
    758     char *curr_xattr_list_fname;
    759     char *curr_acl_list_fname;
     723    char *curr_xattr_list_fname = NULL;
     724    char *curr_acl_list_fname = NULL;
    760725
    761726    /*@ long long *************************************************** */
     
    763728
    764729    assert(bkpinfo != NULL);
    765     malloc_string(tmp);
    766730    malloc_string(fname);
    767     malloc_string(curr_xattr_list_fname);
    768     malloc_string(curr_acl_list_fname);
    769731
    770732    if (g_getfattr) {
    771         sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    772             bkpinfo->tmpdir);
     733        mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    773734    }
    774735    if (g_getfacl) {
    775         sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    776             bkpinfo->tmpdir);
     736        mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    777737    }
    778738    log_to_screen("Verifying regular archives on tape");
     
    796756        wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
    797757    }
     758    if (g_getfattr) {
     759        mr_free(curr_xattr_list_fname);
     760    }
     761    if (g_getfacl) {
     762        mr_free(curr_acl_list_fname);
     763    }
    798764
    799765    for (res = read_header_block_from_stream(&size, fname, &ctrl_chr);
     
    801767         res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
    802768        if (g_getfattr) {
    803             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    804                 bkpinfo->tmpdir, current_afioball_number);
     769            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
    805770        }
    806771        if (g_getfacl) {
    807             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    808                 bkpinfo->tmpdir, current_afioball_number);
     772            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
    809773        }
    810774        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
     
    815779                                          curr_acl_list_fname);
    816780        }
     781        if (g_getfattr) {
     782            mr_free(curr_xattr_list_fname);
     783        }
     784        if (g_getfacl) {
     785            mr_free(curr_acl_list_fname);
     786        }
    817787        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    818788            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    819789        }
    820         sprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
    821         /*log_it(tmp); */
     790        mr_asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);
    822791        update_progress_form(tmp);
     792        mr_free(tmp);
     793
    823794        res = verify_an_afioball_from_stream(fname, size);
    824795        if (res) {
    825             sprintf(tmp, "Afioball %ld differs from live filesystem",
     796            mr_asprintf(&tmp, "Afioball %ld differs from live filesystem",
    826797                    current_afioball_number);
    827798            log_to_screen(tmp);
     799            mr_free(tmp);
    828800        }
    829801        retval += res;
     
    837809    log_msg(1, "All done with afioballs");
    838810    close_progress_form();
    839     paranoid_free(tmp);
    840811    paranoid_free(fname);
    841     paranoid_free(curr_xattr_list_fname);
    842     paranoid_free(curr_acl_list_fname);
    843812    return (retval);
    844813}
     
    865834
    866835    /*@ buffers ******************************************************** */
    867     char *tmp;
    868     char *orig_fname, *logical_fname;
    869     char *comment;
    870     char *curr_xattr_list_fname;
    871     char *curr_acl_list_fname;
     836    char *orig_fname;
     837    char *logical_fname = NULL;
     838    char *comment = NULL;
     839    char *curr_xattr_list_fname = NULL;
     840    char *curr_acl_list_fname = NULL;
    872841    /*@ pointers ******************************************************* */
    873842    char *p;
     
    877846
    878847    assert(bkpinfo != NULL);
    879     malloc_string(tmp);
    880848    malloc_string(orig_fname);
    881     malloc_string(logical_fname);
    882     malloc_string(comment);
    883     malloc_string(curr_xattr_list_fname);
    884     malloc_string(curr_acl_list_fname);
    885849
    886850    if (g_getfattr) {
    887         sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    888             bkpinfo->tmpdir);
     851        mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    889852    }
    890853    if (g_getfacl) {
    891         sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    892             bkpinfo->tmpdir);
    893     }
    894     sprintf(comment, "Verifying all bigfiles.");
     854        mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     855    }
     856    mr_asprintf(&comment, "Verifying all bigfiles.");
    895857    log_to_screen(comment);
    896     sprintf(tmp, "%s/biggielist.txt", bkpinfo->tmpdir);
    897 //  noof_biggiefiles = count_lines_in_file (tmp); // pointless
    898858    res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    899859    if (ctrl_chr != BLK_START_BIGGIEFILES) {
     
    906866        }
    907867    }
     868    if (g_getfattr) {
     869        mr_free(curr_xattr_list_fname);
     870    }
     871    if (g_getfacl) {
     872        mr_free(curr_acl_list_fname);
     873    }
     874
    908875    if (ctrl_chr != BLK_START_BIGGIEFILES) {
    909876        wrong_marker(BLK_START_BIGGIEFILES, ctrl_chr);
     
    914881                       "Please wait. This may take some time.", "",
    915882                       noof_biggiefiles);
     883    mr_free(comment);
     884
    916885    for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    917886         ctrl_chr != BLK_STOP_BIGGIEFILES;
     
    928897            p++;
    929898        }
    930         sprintf(comment, "Verifying bigfile #%ld (%ld K)",
     899        mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)",
    931900                current_biggiefile_number, (long) size >> 10);
    932901        update_progress_form(comment);
    933         sprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    934         res =
    935             verify_a_biggiefile_from_stream(logical_fname, size);
     902        mr_free(comment);
     903
     904        mr_asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
     905        res = verify_a_biggiefile_from_stream(logical_fname, size);
     906        mr_free(logical_fname);
     907
    936908        retval += res;
    937909        current_biggiefile_number++;
     
    940912    close_progress_form();
    941913    paranoid_free(orig_fname);
    942     paranoid_free(logical_fname);
    943     paranoid_free(curr_xattr_list_fname);
    944     paranoid_free(curr_acl_list_fname);
    945     paranoid_free(comment);
    946     paranoid_free(tmp);
    947914    return (retval);
    948915}
     
    10691036
    10701037    /*@ buffers ******************************************************** */
    1071     char *mountpoint;
    1072     char *command;
    1073     char *tmp;
    1074     char *fname;
     1038    char *mountpoint = NULL;
     1039    char *command = NULL;
     1040    char *tmp = NULL;
     1041    char *fname = NULL;
    10751042#ifdef __FreeBSD__
    10761043    char mdd[32];
     
    10821049#endif
    10831050
    1084     command = malloc(2000);
    1085     malloc_string(mountpoint);
    1086     malloc_string(tmp);
    1087     malloc_string(fname);
    1088 
    10891051    assert(bkpinfo != NULL);
    10901052
    1091     sprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
    1092     sprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    1093             bkpinfo->prefix, g_current_media_number);
     1053    mr_asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);
     1054    mr_asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    10941055
    10951056    mkdir(mountpoint, 1777);
    10961057    sync();
    10971058    if (!does_file_exist(fname)) {
    1098         sprintf(tmp,
    1099                 "%s not found; assuming you backed up to CD; verifying CD...",
    1100                 fname);
    1101         log_msg(2, tmp);
     1059        log_msg(2, "%s not found; assuming you backed up to CD; verifying CD...", fname);
    11021060        if (bkpinfo->manual_cd_tray) {
    11031061            popup_and_OK("Please push CD tray closed.");
     
    11051063        if (find_and_mount_actual_cd(mountpoint)) {
    11061064            log_to_screen("failed to mount actual CD");
     1065            mr_free(mountpoint);
     1066            mr_free(fname);
    11071067            return (1);
    11081068        }
    11091069    } else {
    1110         sprintf(tmp, "%s found; verifying ISO...", fname);
     1070        log_msg(2, "%s found; verifying ISO...", fname);
    11111071#ifdef __FreeBSD__
    11121072        ret = 0;
     
    11141074        mddevice = make_vn(fname);
    11151075        if (ret) {
    1116             sprintf(tmp, "make_vn of %s failed; unable to verify ISO\n",
    1117                     fname);
     1076            mr_asprintf(&tmp, "make_vn of %s failed; unable to verify ISO\n", fname);
    11181077            log_to_screen(tmp);
     1078            mr_free(tmp);
     1079            mr_free(mountpoint);
     1080            mr_free(fname);
    11191081            return (1);
    11201082        }
    1121         sprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
     1083        mr_asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);
    11221084#else
    1123         sprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname,
    1124                 mountpoint);
     1085        mr_asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
    11251086#endif
    11261087        if (run_program_and_log_output(command, FALSE)) {
    1127             sprintf(tmp, "%s failed; unable to mount ISO image\n",
    1128                     command);
     1088            mr_asprintf(&tmp, "%s failed; unable to mount ISO image\n", command);
    11291089            log_to_screen(tmp);
     1090            mr_free(tmp);
     1091            mr_free(mountpoint);
     1092            mr_free(command);
     1093            mr_free(fname);
    11301094            return (1);
    11311095        }
     1096        mr_free(command);
    11321097    }
    11331098    log_msg(2, "OK, I've mounted the ISO/CD\n");
    1134     sprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     1099    mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    11351100    if (!does_file_exist(tmp)) {
    11361101        log_msg
     
    11441109*/
    11451110    }
     1111    mr_free(tmp);
     1112
    11461113    verify_afioballs_on_CD(mountpoint);
    11471114    log_it("before verify_all_slices");
     
    11501117#ifdef __FreeBSD__
    11511118    ret = 0;
    1152     sprintf(command, "umount %s", mountpoint);
     1119    mr_asprintf(&command, "umount %s", mountpoint);
    11531120    ret += system(command);
    11541121    ret += kick_vn(mddevice);
    11551122    if (ret)
    11561123#else
    1157     sprintf(command, "umount %s", mountpoint);
     1124    mr_asprintf(&command, "umount %s", mountpoint);
    11581125    if (system(command))
    11591126#endif
    11601127    {
    1161         sprintf(tmp, "%s failed; unable to unmount ISO image\n", command);
     1128        mr_asprintf(&tmp, "%s failed; unable to unmount ISO image\n", command);
    11621129        log_to_screen(tmp);
     1130        mr_free(tmp);
     1131
    11631132        retval++;
    11641133    } else {
    11651134        log_msg(2, "OK, I've unmounted the ISO file\n");
    11661135    }
     1136    mr_free(mountpoint);
     1137    mr_free(command);
     1138
    11671139    if (!does_file_exist(fname)) {
    1168         sprintf(command, "umount %s", bkpinfo->media_device);
     1140        mr_asprintf(&command, "umount %s", bkpinfo->media_device);
    11691141        run_program_and_log_output(command, 2);
     1142        mr_free(command);
     1143
    11701144        if (!bkpinfo->please_dont_eject
    11711145            && eject_device(bkpinfo->media_device)) {
     
    11731147        }
    11741148    }
    1175     paranoid_free(command);
    1176     paranoid_free(mountpoint);
    1177     paranoid_free(tmp);
    1178     paranoid_free(fname);
     1149    mr_free(fname);
    11791150    return (retval);
    11801151}
     
    11941165
    11951166    /*@ buffers ******************************************************** */
    1196     char tmp[MAX_STR_LEN];
    1197     char changed_files_fname[MAX_STR_LEN];
     1167    char *tmp = NULL;
     1168    char *changed_files_fname = NULL;
    11981169
    11991170    /*@ long *********************************************************** */
     
    12141185/* close tape; exit */
    12151186//  fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
    1216     sprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
     1187    mr_asprintf(&tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
    12171188    paranoid_system(tmp);
    1218     sprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
    1219     sprintf(tmp,
    1220             "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s",
    1221             (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
    1222             changed_files_fname);
     1189    mr_free(tmp);
     1190
     1191    mr_asprintf(&changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
     1192    mr_asprintf(&tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
    12231193    log_msg(2, "Running command to derive list of changed files");
    12241194    log_msg(2, tmp);
    12251195    if (system(tmp)) {
    1226         if (does_file_exist(changed_files_fname)
    1227             && length_of_file(changed_files_fname) > 2) {
    1228             log_to_screen
    1229                 ("Warning - unable to check logfile to derive list of changed files");
     1196        if (does_file_exist(changed_files_fname) && length_of_file(changed_files_fname) > 2) {
     1197            log_to_screen("Warning - unable to check logfile to derive list of changed files");
    12301198        } else {
    1231             log_to_screen
    1232                 ("No differences found. Therefore, no 'changed.files' text file.");
    1233         }
    1234     }
    1235     sprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
     1199            log_to_screen("No differences found. Therefore, no 'changed.files' text file.");
     1200        }
     1201    }
     1202    mr_free(tmp);
     1203
     1204    mr_asprintf(&tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
    12361205    paranoid_system(tmp);
     1206    mr_free(tmp);
    12371207
    12381208    diffs = count_lines_in_file(changed_files_fname);
    12391209    if (diffs > 0) {
    1240         sprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname,
     1210        mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname,
    12411211                MONDO_CACHE);
    12421212        run_program_and_log_output(tmp, FALSE);
    1243         sprintf(tmp,
    1244                 "%ld files differed from live filesystem; type less %s or less %s/changed.files to see",
    1245                 diffs, changed_files_fname, MONDO_CACHE);
    1246         log_msg(0, tmp);
     1213        mr_free(tmp);
     1214
     1215        log_msg(0, "%ld files differed from live filesystem; type less %s or less %s/changed.files to see", diffs, changed_files_fname, MONDO_CACHE);
    12471216        log_to_screen("See "MONDO_CACHE"/changed.files for a list of nonmatching files.");
    12481217        log_to_screen("The files probably changed on filesystem, not on backup media.");
    1249         //      retval++;
    1250     }
     1218    }
     1219    mr_free(changed_files_fname);
    12511220    return (retval);
    12521221}
Note: See TracChangeset for help on using the changeset viewer.