Changeset 2287 in MondoRescue


Ignore:
Timestamp:
Jul 21, 2009, 3:26:16 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3289@localhost: bruno | 2009-07-21 15:12:29 +0200

  • Replace sprintf by mr_asprintf in mondorestore.c
  • Remove usless option -pih in mondorestore
Location:
branches/2.2.10/mondo/src
Files:
4 edited

Legend:

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

    r2279 r2287  
    543543    FILE *pin, *pout, *faclin;
    544544
    545     log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist,
    546             original_exat_fname, executable);
     545    log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist, original_exat_fname, executable);
    547546    if (!orig_msklist || !orig_msklist[0]
    548547        || !does_file_exist(orig_msklist)) {
     
    556555    }
    557556    if (length_of_file(original_exat_fname) <= 0) {
    558         log_msg(1,
    559                 "original_exat_fname %s is empty or missing, so no need to set EXAT list",
    560                 original_exat_fname);
     557        log_msg(1, "original_exat_fname %s is empty or missing, so no need to set EXAT list", original_exat_fname);
    561558        return (0);
    562559    }
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2274 r2287  
    802802    in_out[i] = '\0';
    803803    paranoid_free(tmp);
    804 /*  for(i=strlen(in_out); i>0 && in_out[i-1]<=32; i--) {in_out[i-1]='\0';} */
    805804}
    806805
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2282 r2287  
    21852185    device[0] = '\0';
    21862186    chdir(bkpinfo->tmpdir);
    2187     mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);
     2187    mr_asprintf(&cfg_file, "%s", MONDO_CFG_FILE_STUB);
    21882188    unlink(cfg_file);           // cfg_file[] is missing the '/' at the start, FYI, by intent
    21892189    mr_free(cfg_file);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2242 r2287  
    259259              struct raidlist_itself *raidlist)
    260260{
    261     char c, *tmp;
     261    char c;
     262    char *tmp = NULL;
    262263    int retval = 0;
    263264
     
    266267    assert(mountlist != NULL);
    267268    assert(raidlist != NULL);
    268     malloc_string(tmp);
    269269    log_it("pre wrm");
    270270    c = which_restore_mode();
     
    280280        }
    281281        if (g_ISO_restore_mode) {
    282             sprintf(tmp, "umount %s", bkpinfo->isodir);
     282            mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    283283            run_program_and_log_output(tmp, FALSE);
     284            mr_free(tmp);
    284285        }
    285286        paranoid_MR_finish(0);
     
    308309        retval += compare_mode(mountlist, raidlist);
    309310    }
    310     paranoid_free(tmp);
    311311    return (retval);
    312312}
     
    439439  /** needs malloc **********/
    440440    char *tmp;
     441    char *tmp1 = NULL;
    441442    char *fstab_fname;
    442443    char *old_restpath;
     
    496497        if (g_text_mode) {
    497498            save_mountlist_to_disk(mountlist, g_mountlist_fname);
    498             sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
    499             res = system(tmp);
     499            mr_asprintf(&tmp1, "%s %s", find_my_editor(), g_mountlist_fname);
     500            res = system(tmp1);
     501            mr_free(tmp1);
    500502            load_mountlist(mountlist, g_mountlist_fname);
    501503        } else {
     
    666668            strcpy(fstab_fname, "/tmp/fstab");
    667669        }
    668         sprintf(tmp,
     670        mr_asprintf(&tmp1,
    669671                "label-partitions-as-necessary %s < %s >> %s 2>> %s",
    670672                g_mountlist_fname, fstab_fname, MONDO_LOGFILE,
    671673                MONDO_LOGFILE);
    672         res = system(tmp);
     674        res = system(tmp1);
     675        mr_free(tmp1);
    673676        if (res) {
    674677            log_to_screen
     
    776779    bool boot_loader_installed = FALSE;
    777780  /** malloc **/
    778     char tmp[MAX_STR_LEN];
    779     char *tmpA;
    780     char *tmpB;
    781     char *tmpC;
     781    char *tmp = NULL;
     782    char *tmpA = NULL;
     783    char *tmpB = NULL;
     784    char *tmpC = NULL;
    782785
    783786    assert(bkpinfo != NULL);
     
    808811    }
    809812    if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
    810         sprintf(tmp,
     813        mr_asprintf(&tmp,
    811814                "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?",
    812815                tmpA, tmpB, tmpC);
    813         if (ask_me_yes_or_no(tmp)) {
     816        res = ask_me_yes_or_no(tmp);
     817        mr_free(tmp);
     818        if (res) {
    814819            retval = interactive_mode(mountlist, raidlist);
    815820            goto after_the_nuke;
     
    900905                        "Using tune2fs to identify your ext2,3 partitions");
    901906
    902     sprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab",
    903             g_mountlist_fname);
     907    mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab", g_mountlist_fname);
    904908    res = run_program_and_log_output(tmp, TRUE);
     909    mr_free(tmp);
    905910    if (res) {
    906911        log_to_screen("label-partitions-as-necessary returned an error");
     
    920925            ("Please visit our website at http://www.mondorescue.org for more information.");
    921926    } else {
    922         strcpy(tmp,"Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
    923             popup_and_OK(tmp);
     927        mr_asprintf(&tmp,"%s","Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
     928        popup_and_OK(tmp);
     929        mr_free(tmp);
    924930        log_to_screen
    925931          ("Mondo has restored your system. Please wait for the command prompt.");
     
    930936    }
    931937    g_I_have_just_nuked = TRUE;
    932 /*
    933   if (!boot_loader_installed && !does_file_exist(DO_MBR_PLEASE))
    934     {
    935       log_to_screen("PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR");
    936       write_one_liner_data_file(DO_MBR_PLEASE, "mondorestore --mbr");
    937     }
    938 */
    939938    return (retval);
    940939}
     
    10711070
    10721071  /** malloc ***/
    1073     char *checksum, *outfile_fname, *tmp, *bzip2_command,
    1074         *ntfsprog_command, *suffix, *sz_devfile;
     1072    char *checksum;
     1073    char *outfile_fname = NULL;
     1074    char *tmp = NULL;
     1075    char *bzip2_command = NULL;
     1076    char *ntfsprog_command, *suffix;
     1077    char *sz_devfile = NULL;
    10751078    char *bigblk;
    10761079    char *p;
     
    10881091    int res = 0;
    10891092    int old_loglevel;
    1090     char sz_msg[MAX_STR_LEN];
    10911093    struct s_node *node;
    10921094
     
    10961098
    10971099    malloc_string(checksum);
    1098     malloc_string(outfile_fname);
    1099     malloc_string(tmp);
    1100     malloc_string(bzip2_command);
    11011100    malloc_string(ntfsprog_command);
    11021101    malloc_string(suffix);
    1103     malloc_string(sz_devfile);
    11041102
    11051103    pathname_of_last_file_restored[0] = '\0';
     
    11241122
    11251123    if (!checksum[0]) {
    1126         sprintf(tmp, "Warning - bigfile %ld does not have a checksum",
    1127                 bigfileno + 1);
    1128         log_msg(3, tmp);
     1124        log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1);
    11291125        p = checksum;
    11301126    }
     
    11321128    if (!strncmp(biggiestruct.filename, "/dev/", 5))    // Whether NTFS or not :)
    11331129    {
    1134         strcpy(outfile_fname, biggiestruct.filename);
     1130        mr_asprintf(&outfile_fname, "%s", biggiestruct.filename);
    11351131    } else {
    1136         sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,
    1137                 biggiestruct.filename);
     1132        mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    11381133    }
    11391134
     
    11701165        g_loglevel = 4;
    11711166        use_ntfsprog_hack = TRUE;
    1172         log_msg(2,
    1173                 "Calling ntfsclone in background because %s is an NTFS /dev entry",
    1174                 outfile_fname);
    1175         sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
     1167        log_msg(2, "Calling ntfsclone in background because %s is an NTFS /dev entry", outfile_fname);
     1168        mr_asprintf(&sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
    11761169                (int) (random() % 32768));
    11771170        mkfifo(sz_devfile, 0x770);
    11781171        strcpy(ntfsprog_fifo, sz_devfile);
     1172        mr_free(sz_devfile);
    11791173        file_to_openout = ntfsprog_fifo;
    11801174        switch (pid = fork()) {
     
    12061200    }
    12071201
    1208     sprintf(tmp, "Reassembling big file %ld (%s)", bigfileno + 1,
    1209             outfile_fname);
    1210     log_msg(2, tmp);
     1202    log_msg(2, "Reassembling big file %ld (%s)", bigfileno + 1, outfile_fname);
    12111203
    12121204    /*
     
    12441236            g_current_media_number++;
    12451237            mds = media_descriptor_string(bkpinfo->backup_media_type);
    1246             sprintf(tmp,
    1247                     "Asking for %s #%d so that I may read slice #%ld\n", mds,
    1248                     g_current_media_number, sliceno);
    1249             log_msg(2, tmp);
    1250             sprintf(tmp, "Restoring from %s #%d", mds, g_current_media_number);
     1238            log_msg(2, "Asking for %s #%d so that I may read slice #%ld\n", mds, g_current_media_number, sliceno);
    12511239            mr_free(mds);
    12521240
     1241            mr_asprintf(&tmp, "Restoring from %s #%d", mds, g_current_media_number);
    12531242            log_to_screen(tmp);
     1243            mr_free(tmp);
     1244
    12541245            insist_on_this_cd_number(g_current_media_number);
    12551246            log_to_screen("Continuing to restore.");
    12561247        } else {
    1257             strcpy(tmp,
    1258                    slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));
     1248            mr_asprintf(&tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));
    12591249            if (does_file_exist(tmp) && length_of_file(tmp) == 0) {
    12601250                log_msg(2,
     
    12621252                        bigfileno + 1, sliceno);
    12631253                finished = TRUE;
     1254                mr_free(tmp);
    12641255                continue;
    12651256            } else {
     
    12671258                    (slice_fname
    12681259                     (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) {
    1269                     strcpy(bzip2_command, "lzop");
     1260                    mr_asprintf(&bzip2_command, "lzop");
    12701261                    strcpy(suffix, "lzo");
    12711262                } else
     
    12731264                        (slice_fname
    12741265                         (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) {
    1275                     strcpy(bzip2_command, "gzip");
     1266                    mr_asprintf(&bzip2_command, "gzip");
    12761267                    strcpy(suffix, "gz");
    12771268                } else
     
    12791270                        (slice_fname
    12801271                         (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
    1281                     strcpy(bzip2_command, "bzip2");
     1272                    mr_asprintf(&bzip2_command, "bzip2");
    12821273                    strcpy(suffix, "bz2");
    12831274                } else
     
    12851276                        (slice_fname
    12861277                         (bigfileno, sliceno, ARCHIVES_PATH, ""))) {
    1287                     strcpy(bzip2_command, "");
     1278                    mr_asprintf(&bzip2_command, "");
    12881279                    strcpy(suffix, "");
    12891280                } else {
    12901281                    log_to_screen("OK, that's pretty fsck0red...");
     1282                    mr_free(tmp);
    12911283                    return (1);
    12921284                }
    12931285            }
    1294             if (bzip2_command[0] != '\0') {
    1295                 sprintf(bzip2_command + strlen(bzip2_command),
    1296                         " -dc %s 2>> %s",
    1297                         slice_fname(bigfileno, sliceno, ARCHIVES_PATH,
    1298                                     suffix), MONDO_LOGFILE);
     1286            mr_free(tmp);
     1287            if (bzip2_command != NULL) {
     1288                mr_strcat(bzip2_command, " -dc %s 2>> %s",
     1289                        slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE);
    12991290            } else {
    1300                 sprintf(bzip2_command, "cat %s 2>> %s",
    1301                         slice_fname(bigfileno, sliceno, ARCHIVES_PATH,
    1302                                     suffix), MONDO_LOGFILE);
     1291                mr_asprintf(&bzip2_command, "cat %s 2>> %s",
     1292                        slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE);
    13031293            }
    13041294            mds = media_descriptor_string(bkpinfo->backup_media_type);
    1305             sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds,
     1295            mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds,
    13061296                    g_current_media_number, bigfileno + 1, sliceno);
    13071297            mr_free(mds);
     
    13141304                update_progress_form(tmp);
    13151305            }
     1306            mr_free(tmp);
     1307
    13161308            if (!(fbzip2 = popen(bzip2_command, "r"))) {
    13171309                fatal_error("Can't run popen command");
    13181310            }
     1311            mr_free(bzip2_command);
     1312
    13191313            while (!feof(fbzip2)) {
    13201314                siz = fread(bigblk, 1, TAPE_BLOCK_SIZE, fbzip2);
    13211315                if (siz > 0) {
    1322                     sprintf(sz_msg, "Read %ld from fbzip2", siz);
    13231316                    siz = fwrite(bigblk, 1, siz, fout);
    1324                     sprintf(sz_msg + strlen(sz_msg),
    1325                             "; written %ld to fout", siz);
    1326 //        log_msg(2. sz_msg);
    13271317                }
    13281318            }
     
    13341324        }
    13351325    }
    1336 /*
    1337   memset(bigblk, TAPE_BLOCK_SIZE, 1); // This all looks very fishy...
    1338   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1339   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1340   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1341   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1342 */
    13431326    paranoid_fclose(fout);
    13441327    g_loglevel = old_loglevel;
     
    13461329    if (use_ntfsprog_hack) {
    13471330        log_msg(3, "Waiting for ntfsclone to finish");
    1348         sprintf(tmp,
     1331        mr_asprintf(&tmp,
    13491332                " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    13501333        while (system(tmp) == 0) {
    13511334            sleep(1);
    13521335        }
     1336        mr_free(tmp);
    13531337        log_it("OK, ntfsclone has really finished");
    13541338    }
    13551339
    13561340    if (strcmp(outfile_fname, "/dev/null")) {
    1357         chown(outfile_fname, biggiestruct.properties.st_uid,
    1358               biggiestruct.properties.st_gid);
     1341        chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
    13591342        chmod(outfile_fname, biggiestruct.properties.st_mode);
    13601343        ubuf->actime = biggiestruct.properties.st_atime;
     
    13621345        utime(outfile_fname, ubuf);
    13631346    }
     1347    mr_free(outfile_fname);
    13641348    paranoid_free(bigblk);
    13651349    paranoid_free(checksum);
    1366     paranoid_free(outfile_fname);
    1367     paranoid_free(tmp);
    1368     paranoid_free(bzip2_command);
    13691350    paranoid_free(ntfsprog_command);
    13701351    paranoid_free(suffix);
    1371     paranoid_free(sz_devfile);
    13721352
    13731353    return (retval);
     
    14041384
    14051385  /** mallocs ********/
    1406     char *tmp;
    1407     char *command;
    1408     char *outfile_fname;
     1386    char *tmp = NULL;
     1387    char *tmp1 = NULL;
     1388    char *command = NULL;
     1389    char *outfile_fname = NULL;
    14091390    char *ntfsprog_command;
    1410     char *sz_devfile;
     1391    char *sz_devfile = NULL;
    14111392    char *ntfsprog_fifo;
    14121393    char *file_to_openout = NULL;
     
    14291410    malloc_string(tmp);
    14301411    malloc_string(ntfsprog_fifo);
    1431     malloc_string(outfile_fname);
    1432     malloc_string(command);
    1433     malloc_string(sz_devfile);
    14341412    malloc_string(ntfsprog_command);
    14351413    old_loglevel = g_loglevel;
     
    14831461    if (use_ntfsprog) {
    14841462        g_loglevel = 4;
    1485         strcpy(outfile_fname, orig_bf_fname);
     1463        mr_asprintf(&outfile_fname, "%s", orig_bf_fname);
    14861464        use_ntfsprog_hack = TRUE;
    1487         log_msg(2,
    1488                 "Calling ntfsclone in background because %s is a /dev entry",
    1489                 outfile_fname);
    1490         sprintf(sz_devfile, "%s/%d.%d.000",
     1465        log_msg(2, "Calling ntfsclone in background because %s is a /dev entry", outfile_fname);
     1466        mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    14911467                bkpinfo->tmpdir,
    14921468                (int) (random() % 32768),
     
    14941470        mkfifo(sz_devfile, 0x770);
    14951471        strcpy(ntfsprog_fifo, sz_devfile);
     1472        mr_free(sz_devfile);
     1473
    14961474        file_to_openout = ntfsprog_fifo;
    14971475        switch (pid = fork()) {
     
    14991477            fatal_error("Fork failure");
    15001478        case 0:
    1501             log_msg(3,
    1502                     "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
    1503                     outfile_fname, ntfsprog_fifo);
    1504             res =
    1505                 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    1506 //          log_msg(3, "CHILD - fip - exiting");
     1479            log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo);
     1480            res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    15071481            exit(res);
    15081482            break;
    15091483        default:
    1510             log_msg(3,
    1511                     "feed_into_ntfsprog() called in background --- pid=%ld",
    1512                     (long int) (pid));
     1484            log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
    15131485        }
    15141486    } else {
    1515         if (!strncmp(orig_bf_fname, "/dev/", 5))    // non-NTFS partition
    1516         {
    1517             strcpy(outfile_fname, orig_bf_fname);
    1518         } else                  // biggiefile
    1519         {
    1520             sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,
    1521                     orig_bf_fname);
     1487        if (!strncmp(orig_bf_fname, "/dev/", 5))    {
     1488            // non-NTFS partition
     1489            mr_asprintf(&outfile_fname, "%s", orig_bf_fname);
     1490        } else {
     1491            // biggiefile
     1492            mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, orig_bf_fname);
    15221493        }
    15231494        use_ntfsprog_hack = FALSE;
     
    15281499            make_hole_for_file(outfile_fname);
    15291500        }
    1530         sprintf(tmp, "Reassembling big file %ld (%s)",
    1531                 biggiefile_number + 1, orig_bf_fname);
    1532         log_msg(2, tmp);
     1501        log_msg(2, "Reassembling big file %ld (%s)", biggiefile_number + 1, orig_bf_fname);
    15331502    }
    15341503
    15351504    if (dummy_restore) {
    1536         sprintf(outfile_fname, "/dev/null");
     1505        mr_free(outfile_fname);
     1506        mr_asprintf(&outfile_fname, "/dev/null");
    15371507    }
    15381508
    15391509    if (!bkpinfo->zip_exe[0]) {
    1540         sprintf(command, "cat > \"%s\"", file_to_openout);
     1510        mr_asprintf(&command, "cat > \"%s\"", file_to_openout);
    15411511    } else {
    1542         sprintf(command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,
    1543                 file_to_openout, MONDO_LOGFILE);
     1512        mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, file_to_openout, MONDO_LOGFILE);
    15441513        if (strcmp(bkpinfo->zip_exe, "gzip") == 0) {
    15451514            /* Ignore SIGPIPE for gzip as it causes errors on big files
    1546              * Cf: http://trac.mondorescue.org/ticket/244
    1547              */
     1515             * Cf: http://trac.mondorescue.org/ticket/244 */
    15481516            signal(SIGPIPE,SIG_IGN);
    15491517        }
    15501518    }
    1551     sprintf(tmp, "Pipe command = '%s'", command);
    1552     log_msg(3, tmp);
     1519    log_msg(3, "Pipe command = '%s'", command);
    15531520
    15541521    /* restore biggiefile, one slice at a time */
     
    15561523        fatal_error("Cannot pipe out");
    15571524    }
     1525    mr_free(command);
     1526
    15581527    for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
    15591528         ctrl_chr != BLK_STOP_A_BIGGIE;
     
    15621531            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    15631532        }
    1564         sprintf(tmp, "Working on file #%ld, slice #%ld    ",
    1565                 biggiefile_number + 1, current_slice_number);
    1566         log_msg(2, tmp);
     1533        log_msg(2, "Working on file #%ld, slice #%ld    ", biggiefile_number + 1, current_slice_number);
    15671534        if (!g_text_mode) {
    15681535            newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    16031570    if (bkpinfo->zip_exe[0]) {
    16041571        if (strcmp(bkpinfo->zip_exe, "gzip") == 0) {
    1605             /* Re-enable SIGPIPE for gzip
    1606              */
     1572            /* Re-enable SIGPIPE for gzip */
    16071573            signal(SIGPIPE, terminate_daemon);
    16081574        }
     
    16141580    if (use_ntfsprog_hack) {
    16151581        log_msg(3, "Waiting for ntfsclone to finish");
    1616         sprintf(tmp,
    1617                 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    1618         while (system(tmp) == 0) {
     1582        mr_asprintf(&tmp1, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
     1583        while (system(tmp1) == 0) {
    16191584            sleep(1);
    16201585        }
     1586        mr_free(tmp1);
    16211587        log_msg(3, "OK, ntfsclone has really finished");
    16221588    }
     
    16261592    if (strcmp(outfile_fname, "/dev/null")) {
    16271593        chmod(outfile_fname, biggiestruct.properties.st_mode);
    1628         chown(outfile_fname, biggiestruct.properties.st_uid,
    1629               biggiestruct.properties.st_gid);
     1594        chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
    16301595        ubuf->actime = biggiestruct.properties.st_atime;
    16311596        ubuf->modtime = biggiestruct.properties.st_mtime;
    16321597        utime(outfile_fname, ubuf);
    16331598    }
     1599    mr_free(outfile_fname);
    16341600
    16351601    paranoid_free(tmp);
    1636     paranoid_free(outfile_fname);
    1637     paranoid_free(command);
    16381602    paranoid_free(ntfsprog_command);
    1639     paranoid_free(sz_devfile);
    16401603    paranoid_free(ntfsprog_fifo);
    16411604    g_loglevel = old_loglevel;
     
    16711634  /** malloc **/
    16721635    char *command = NULL;
    1673     char *tmp;
    1674     char *filelist_name;
    1675     char *filelist_subset_fname;
    1676     char *executable;
    1677     char *temp_log;
    1678     char screen_message[100];
     1636    char *tmp = NULL;
     1637    char *filelist_name = NULL;
     1638    char *filelist_subset_fname = NULL;
     1639    char *executable = NULL;
     1640    char *temp_log = NULL;
     1641    char *screen_message = NULL;
    16791642    long matches = 0;
    16801643    bool use_star;
    1681     char *xattr_fname;
    1682     char *acl_fname;
    1683 //  char files_to_restore_this_time_fname[MAX_STR_LEN];
     1644    char *xattr_fname = NULL;
     1645    char *acl_fname = NULL;
    16841646
    16851647    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    1686     malloc_string(tmp);
    1687     malloc_string(filelist_name);
    1688     malloc_string(filelist_subset_fname);
    1689     malloc_string(executable);
    1690     malloc_string(temp_log);
    1691     malloc_string(xattr_fname);
    1692     malloc_string(acl_fname);
    16931648
    16941649    log_msg(5, "Entering");
    1695     filelist_subset_fname[0] = '\0';
    16961650    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    1697 //  sprintf(files_to_restore_this_time_fname, "/tmp/ftrttf.%d.%d", (int)getpid(), (int)random());
    16981651    mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);
    16991652    run_program_and_log_output(command, 9);
    17001653    paranoid_free(command);
    17011654
    1702     sprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768),
    1703             (int) (random() % 32768));
    1704 
    1705     sprintf(filelist_name, MNT_CDROM "/archives/filelist.%ld",
    1706             current_tarball_number);
     1655    mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld", current_tarball_number);
    17071656    if (length_of_file(filelist_name) <= 2) {
    1708         log_msg(2, "There are _zero_ files in filelist '%s'",
    1709                 filelist_name);
    1710         log_msg(2,
    1711                 "This is a bit silly (ask dev-team to fix mondo_makefilelist, please)");
    1712         log_msg(2,
    1713                 "but it's non-critical. It's cosmetic. Don't worry about it.");
     1657        log_msg(2, "There are _zero_ files in filelist '%s'", filelist_name);
     1658        log_msg(2, "This is a bit silly (ask dev-team to fix mondo_makefilelist, please)");
     1659        log_msg(2, "but it's non-critical. It's cosmetic. Don't worry about it.");
    17141660        retval = 0;
    1715         goto leave_sub;
    1716     }
    1717     if (count_lines_in_file(filelist_name) <= 0
    1718         || length_of_file(tarball_fname) <= 0) {
     1661        mr_free(filelist_name);
     1662        log_msg(5, "Leaving");
     1663        return(0);
     1664    }
     1665    if (count_lines_in_file(filelist_name) <= 0 || length_of_file(tarball_fname) <= 0) {
    17191666        log_msg(3, "length_of_file(%s) = %llu", tarball_fname, length_of_file(tarball_fname));
    17201667        log_msg(3, "count_lines_in_file(%s) = %llu", tarball_fname, count_lines_in_file(tarball_fname));
    1721         sprintf(tmp, "Unable to restore fileset #%ld (CD I/O error)",
    1722                 current_tarball_number);
     1668        mr_asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)", current_tarball_number);
    17231669        log_to_screen(tmp);
    1724         retval = 1;
    1725         goto leave_sub;
     1670        mr_free(tmp);
     1671        mr_free(filelist_name);
     1672        log_msg(5, "Leaving");
     1673        return(1);
    17261674    }
    17271675
    17281676    if (filelist) {
    1729         sprintf(filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",
    1730                 current_tarball_number);
     1677        mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", current_tarball_number);
    17311678        if ((matches =
    17321679             save_filelist_entries_in_common(filelist_name, filelist,
    17331680                                             filelist_subset_fname,
    1734                                              use_star))
    1735             <= 0) {
    1736             sprintf(tmp, "Skipping fileset %ld", current_tarball_number);
    1737             log_msg(1, tmp);
     1681                                             use_star)) <= 0) {
     1682            log_msg(1, "Skipping fileset %ld", current_tarball_number);
    17381683        } else {
    1739             log_msg(3, "Saved fileset %ld's subset to %s",
    1740                     current_tarball_number, filelist_subset_fname);
    1741         }
    1742         sprintf(screen_message, "Tarball #%ld --- %ld matches",
     1684            log_msg(3, "Saved fileset %ld's subset to %s", current_tarball_number, filelist_subset_fname);
     1685        }
     1686        mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches",
    17431687                current_tarball_number, matches);
    17441688        log_to_screen(screen_message);
    1745     } else {
    1746         filelist_subset_fname[0] = '\0';
    1747     }
     1689        mr_free(screen_message);
     1690    }
     1691    mr_free(filelist_name);
    17481692
    17491693    if (filelist == NULL || matches > 0) {
    17501694        if (g_getfattr) {
    1751             sprintf(xattr_fname, XATTR_LIST_FNAME_RAW_SZ,
    1752                 MNT_CDROM "/archives", current_tarball_number);
     1695            mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", current_tarball_number);
    17531696        }
    17541697        if (g_getfacl) {
    1755             sprintf(acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",
    1756                 current_tarball_number);
     1698            mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", current_tarball_number);
    17571699        }
    17581700        if (strstr(tarball_fname, ".bz2")) {
    1759             strcpy(executable, "bzip2");
     1701            mr_asprintf(&executable, "bzip2");
    17601702        } else if (strstr(tarball_fname, ".gz")) {
    1761             strcpy(executable, "gzip");
     1703            mr_asprintf(&executable, "gzip");
    17621704        } else if (strstr(tarball_fname, ".lzo")) {
    1763             strcpy(executable, "lzop");
    1764         } else {
    1765             executable[0] = '\0';
    1766         }
    1767         if (executable[0]) {
    1768             sprintf(tmp, "which %s > /dev/null 2> /dev/null", executable);
    1769             if (run_program_and_log_output(tmp, FALSE)) {
    1770                 log_to_screen
    1771                     ("(compare_a_tarball) Compression program %s not found - oh no!", executable);
     1705            mr_asprintf(&executable, "lzop");
     1706        }
     1707        if (executable) {
     1708            mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);
     1709            res = run_program_and_log_output(tmp, FALSE);
     1710            mr_free(tmp);
     1711
     1712            if (res) {
     1713                log_to_screen("(compare_a_tarball) Compression program %s not found - oh no!", executable);
    17721714                paranoid_MR_finish(1);
    17731715            }
    1774             strcpy(tmp, executable);
    1775             sprintf(executable, "-P %s -Z", tmp);
     1716            tmp = executable;
     1717            mr_asprintf(&executable, "-P %s -Z", tmp);
     1718            mr_free(tmp);
    17761719        }
    17771720#ifdef __FreeBSD__
     
    17811724#endif
    17821725
    1783 //      if (strstr(tarball_fname, ".star."))
    17841726        if (use_star) {
    17851727            mr_asprintf(&command,
     
    17901732            }
    17911733        } else {
    1792             if (filelist_subset_fname[0] != '\0') {
    1793                 mr_asprintf(&command,
     1734            if (! executable) {
     1735                log_msg(2, "Mo executable, this shouldn't happen !");
     1736            } else {
     1737                if (filelist_subset_fname != NULL) {
     1738                    mr_asprintf(&command,
    17941739                        "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s",
    17951740                        TAPE_BLOCK_SIZE,
    17961741                        BUFSIZE, executable, filelist_subset_fname,
    1797 //             files_to_restore_this_time_fname,
    17981742                        tarball_fname);
    1799             } else {
    1800                 mr_asprintf(&command,
     1743                } else {
     1744                    mr_asprintf(&command,
    18011745                        "afio -i -b %ld -c %ld -M 8m %s %s",
    18021746                        TAPE_BLOCK_SIZE,
    18031747                        BUFSIZE, executable, tarball_fname);
    1804             }
    1805         }
     1748                }
     1749            }
     1750        }
     1751        mr_free(executable);
    18061752
    18071753#undef BUFSIZE
     1754        mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), (int) (random() % 32768));
     1755
    18081756        mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log);
    18091757        log_msg(1, "command = '%s'", command);
     
    18291777                res = set_fattr_list(filelist_subset_fname, xattr_fname);
    18301778                if (res) {
    1831                     log_to_screen
    1832                         ("Errors occurred while setting extended attributes");
     1779                    log_to_screen("Errors occurred while setting extended attributes");
    18331780                } else {
    18341781                    log_msg(1, "I set xattr OK");
     
    18601807            log_msg(2, "Fileset #%d processed OK", current_tarball_number);
    18611808        }
     1809        unlink(temp_log);
     1810        mr_free(temp_log);
    18621811    }
    18631812    if (does_file_exist("/PAUSE")) {
     
    18661815    }
    18671816    unlink(filelist_subset_fname);
    1868     unlink(xattr_fname);
    1869     unlink(acl_fname);
    1870     unlink(temp_log);
    1871 
    1872   leave_sub:
    1873     paranoid_free(tmp);
    1874     paranoid_free(filelist_name);
    1875     paranoid_free(filelist_subset_fname);
    1876     paranoid_free(executable);
    1877     paranoid_free(temp_log);
    1878     paranoid_free(xattr_fname);
    1879     paranoid_free(acl_fname);
     1817    mr_free(filelist_subset_fname);
     1818    if (g_getfattr) {
     1819        unlink(xattr_fname);
     1820        mr_free(xattr_fname);
     1821    }
     1822    if (g_getfacl) {
     1823        unlink(acl_fname);
     1824        mr_free(acl_fname);
     1825    }
     1826
    18801827    log_msg(5, "Leaving");
    18811828    return (retval);
     
    19131860
    19141861  /** malloc add ***/
    1915     char *tmp;
    19161862    char *mds = NULL;
    1917     char *command;
    1918     char *afio_fname;
    1919     char *filelist_fname;
    1920     char *filelist_subset_fname;
    1921     char *executable;
     1863    char *command = NULL;
     1864    char *afio_fname = NULL;
     1865    char *filelist_fname = NULL;
     1866    char *filelist_subset_fname = NULL;
     1867    char *executable = NULL;
    19221868    long matches = 0;
    19231869    bool restore_this_fileset = FALSE;
     
    19261872    assert(bkpinfo != NULL);
    19271873    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    1928     malloc_string(filelist_subset_fname);
    1929     malloc_string(filelist_fname);
    1930     malloc_string(afio_fname);
    1931     malloc_string(executable);
    1932     malloc_string(command);
    1933     malloc_string(tmp);
    1934     filelist_subset_fname[0] = '\0';
     1874
    19351875    /* to do it with a file... */
    19361876    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    19371877    mds = media_descriptor_string(bkpinfo->backup_media_type);
    1938     sprintf(tmp,
    1939             "Restoring from fileset #%ld (%ld KB) on %s #%d",
     1878    log_msg(2, "Restoring from fileset #%ld (%ld KB) on %s #%d",
    19401879            current_tarball_number, (long) size >> 10, mds, g_current_media_number);
    19411880    mr_free(mds);
    19421881
    1943     log_msg(2, tmp);
    19441882    run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE);
    19451883
     
    19491887   * in afio or someting; oh darn.. OK, use tmpfs :-)                         *
    19501888   ****************************************************************************/
    1951     filelist_fname[0] = filelist_subset_fname[0] = '\0';
    1952     sprintf(afio_fname, "/tmp/tmpfs/archive.tmp.%ld",
    1953             current_tarball_number);
    1954     sprintf(filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,
    1955             current_tarball_number);
    1956     sprintf(filelist_subset_fname, "%s/filelist-subset-%ld.tmp",
    1957             bkpinfo->tmpdir, current_tarball_number);
    1958 //  sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number);
     1889    mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld", current_tarball_number);
     1890    mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, current_tarball_number);
     1891    mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp", bkpinfo->tmpdir, current_tarball_number);
     1892
    19591893    res = read_file_from_stream_to_file(afio_fname, size);
    19601894    if (strstr(tarball_fname, ".star")) {
     
    19651899    }
    19661900    if (bkpinfo->compression_level == 0) {
    1967         executable[0] = '\0';
     1901        mr_asprintf(&executable, "%s", "");
    19681902    } else {
    19691903        if (bkpinfo->use_star) {
    1970             strcpy(executable, " -bz");
     1904            mr_asprintf(&executable, "%s", " -bz");
    19711905        } else {
    1972             sprintf(executable, "-P %s -Z", bkpinfo->zip_exe);
     1906            mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);
    19731907        }
    19741908    }
     
    19811915        if (strstr(tarball_fname, ".star.")) {
    19821916            use_star = TRUE;
    1983             sprintf(command, "star -t file=%s %s", afio_fname, executable);
     1917            mr_asprintf(&command, "star -t file=%s %s", afio_fname, executable);
    19841918        } else {
    19851919            use_star = FALSE;
    1986             sprintf(command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE,
    1987                     executable, afio_fname);
    1988         }
    1989         sprintf(command + strlen(command), " > %s 2>> %s", filelist_fname,
    1990                 MONDO_LOGFILE);
     1920            mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE, executable, afio_fname);
     1921        }
     1922        mr_strcat(command, " > %s 2>> %s", filelist_fname, MONDO_LOGFILE);
    19911923        log_msg(1, "command = %s", command);
    19921924        if (system(command)) {
    19931925            log_msg(4, "Warning - error occurred while retrieving TOC");
    19941926        }
     1927        mr_free(command);
     1928
    19951929        if ((matches =
    19961930             save_filelist_entries_in_common(filelist_fname, filelist,
     
    20021936                        current_tarball_number);
    20031937            }
    2004             sprintf(tmp, "Skipping fileset %ld", current_tarball_number);
    2005             log_msg(2, tmp);
     1938            log_msg(2, "Skipping fileset %ld", current_tarball_number);
    20061939            restore_this_fileset = FALSE;
    20071940        } else {
     
    20141947
    20151948// Concoct the call to star/afio to restore files
    2016     if (strstr(tarball_fname, ".star."))    // star
    2017     {
    2018         sprintf(command, "star -x file=%s %s", afio_fname, executable);
     1949    if (strstr(tarball_fname, ".star.")) {
     1950        // star
     1951        mr_asprintf(&command, "star -x file=%s %s", afio_fname, executable);
    20191952        if (filelist) {
    2020             sprintf(command + strlen(command), " list=%s",
    2021                     filelist_subset_fname);
    2022         }
    2023     } else                      // afio
    2024     {
    2025         sprintf(command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE,
    2026                 executable);
     1953            mr_strcat(command, " list=%s", filelist_subset_fname);
     1954        }
     1955    } else {
     1956        // afio
     1957        mr_asprintf(&command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE, executable);
    20271958        if (filelist) {
    2028             sprintf(command + strlen(command), " -w %s",
    2029                     filelist_subset_fname);
    2030         }
    2031         sprintf(command + strlen(command), " %s", afio_fname);
    2032     }
    2033     sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);
     1959            mr_strcat(command, " -w %s", filelist_subset_fname);
     1960        }
     1961        mr_strcat(command, " %s", afio_fname);
     1962    }
     1963    mr_strcat(command, " 2>> %s", MONDO_LOGFILE);
     1964    mr_free(executable);
    20341965
    20351966// Call if IF there are files to restore (selectively/unconditionally)
     
    20631994        log_msg(1, "NOT CALLING '%s'", command);
    20641995    }
     1996    mr_free(command);
    20651997
    20661998    if (does_file_exist("/PAUSE") && current_tarball_number >= 50) {
     
    20702002
    20712003    unlink(filelist_subset_fname);
     2004    mr_free(filelist_subset_fname);
    20722005    unlink(filelist_fname);
     2006    mr_free(filelist_fname);
    20732007    unlink(afio_fname);
    2074 
    2075     paranoid_free(filelist_subset_fname);
    2076     paranoid_free(filelist_fname);
    2077     paranoid_free(afio_fname);
    2078     paranoid_free(command);
    2079     paranoid_free(tmp);
     2008    mr_free(afio_fname);
     2009
    20802010    return (retval);
    20812011}
     
    21052035  /** malloc **/
    21062036    char *tmp;
     2037    char *tmp1 = NULL;
    21072038    char *mds = NULL;
    21082039    bool just_changed_cds = FALSE;
    2109     char *xattr_fname;
    2110     char *acl_fname;
    2111     char *biggies_whose_EXATs_we_should_set;    // EXtended ATtributes
     2040    char *xattr_fname = NULL;
     2041    char *acl_fname = NULL;
     2042    char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
    21122043    char *pathname_of_last_biggie_restored;
    21132044    FILE *fbw = NULL;
    21142045
    2115     malloc_string(xattr_fname);
    2116     malloc_string(acl_fname);
    21172046    malloc_string(tmp);
    2118     malloc_string(biggies_whose_EXATs_we_should_set);
    21192047    malloc_string(pathname_of_last_biggie_restored);
    21202048    assert(bkpinfo != NULL);
    21212049
    2122     sprintf(biggies_whose_EXATs_we_should_set,
    2123             "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
     2050    mr_asprintf(&biggies_whose_EXATs_we_should_set, "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    21242051    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
    2125         log_msg(1, "Warning - cannot openout %s",
    2126                 biggies_whose_EXATs_we_should_set);
     2052        log_msg(1, "Warning - cannot openout %s", biggies_whose_EXATs_we_should_set);
    21272053    }
    21282054
    21292055    read_cfg_var(g_mondo_cfg_file, "total-slices", tmp);
    21302056    total_slices = atol(tmp);
    2131     sprintf(tmp, "Reassembling large files      ");
    2132     mvaddstr_and_log_it(g_currentY, 0, tmp);
     2057    mr_asprintf(&tmp1, "Reassembling large files      ");
     2058    mvaddstr_and_log_it(g_currentY, 0, tmp1);
     2059    mr_free(tmp1);
     2060
    21332061    if (length_of_file(BIGGIELIST) < 6) {
    21342062        log_msg(1, "OK, no biggielist; not restoring biggiefiles");
     
    21372065    noof_biggiefiles = count_lines_in_file(BIGGIELIST);
    21382066    if (noof_biggiefiles <= 0) {
    2139         log_msg(2,
    2140                 "OK, no biggiefiles in biggielist; not restoring biggiefiles");
     2067        log_msg(2, "OK, no biggiefiles in biggielist; not restoring biggiefiles");
    21412068        return (0);
    21422069    }
    2143     sprintf(tmp, "OK, there are %ld biggiefiles in the archives",
    2144             noof_biggiefiles);
    2145     log_msg(2, tmp);
     2070    log_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles);
    21462071
    21472072    open_progress_form("Reassembling large files",
     
    21522077        log_msg(2, "Thinking about restoring bigfile %ld", bigfileno + 1);
    21532078        if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
    2154             log_msg(3,
    2155                     "...but its first slice isn't on this CD. Perhaps this was a selective restore?");
     2079            log_msg(3, "...but its first slice isn't on this CD. Perhaps this was a selective restore?");
    21562080            mds = media_descriptor_string(bkpinfo->backup_media_type);
    2157             log_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d",
    2158                     bigfileno + 1, mds,
    2159                     g_current_media_number);
     2081            log_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d", bigfileno + 1, mds, g_current_media_number);
    21602082            log_msg(3, "Slicename would have been %s",
    21612083                    slice_fname(bigfileno, 0, ARCHIVES_PATH, ""));
     
    21632085            if (just_changed_cds) {
    21642086                just_changed_cds = FALSE;
    2165                 log_msg(3,
    2166                         "I'll continue to scan this CD for bigfiles to be restored.");
     2087                log_msg(3, "I'll continue to scan this CD for bigfiles to be restored.");
    21672088            } else if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
    21682089                insist_on_this_cd_number(++g_current_media_number);
    2169                 sprintf(tmp, "Restoring from %s #%d", mds,
    2170                         g_current_media_number);
    2171                 log_to_screen(tmp);
     2090                mr_asprintf(&tmp1, "Restoring from %s #%d", mds, g_current_media_number);
     2091                log_to_screen(tmp1);
     2092                mr_free(tmp1);
    21722093                just_changed_cds = TRUE;
    21732094            } else {
    21742095                /* That big file doesn't exist, but the followings may */
    21752096                /* So we need to continue looping */
    2176                 log_msg(2, "There was no bigfile #%ld. That's OK.",
    2177                     bigfileno + 1);
     2097                log_msg(2, "There was no bigfile #%ld. That's OK.", bigfileno + 1);
    21782098                log_msg(2, "I'm going to stop restoring bigfiles now.");
    21792099                retval++;
     
    21832103        } else {
    21842104            just_changed_cds = FALSE;
    2185             sprintf(tmp, "Restoring big file %ld", bigfileno + 1);
    2186             update_progress_form(tmp);
    2187             res =
    2188                 restore_a_biggiefile_from_CD(bigfileno, filelist, pathname_of_last_biggie_restored);
     2105            mr_asprintf(&tmp1, "Restoring big file %ld", bigfileno + 1);
     2106            update_progress_form(tmp1);
     2107            mr_free(tmp1);
     2108            res = restore_a_biggiefile_from_CD(bigfileno, filelist, pathname_of_last_biggie_restored);
    21892109            log_it("%s",pathname_of_last_biggie_restored);
    21902110            if (fbw && pathname_of_last_biggie_restored[0]) {
     
    22002120        fclose(fbw);
    22012121        if (g_getfattr) {
    2202             sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2122            mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    22032123            if (length_of_file(xattr_fname) > 0) {
    22042124                set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
    22052125            }
     2126            mr_free(xattr_fname);
    22062127        }
    22072128        if (g_getfacl) {
    2208             sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2129            mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    22092130            if (length_of_file(acl_fname) > 0) {
    22102131                set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    22112132            }
    2212         }
    2213     }
     2133            mr_free(acl_fname);
     2134        }
     2135    }
     2136    mr_free(biggies_whose_EXATs_we_should_set);
     2137
    22142138    if (does_file_exist("/PAUSE")) {
    2215         popup_and_OK
    2216             ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
     2139        popup_and_OK("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
    22172140    }
    22182141    close_progress_form();
     
    22222145        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    22232146    }
    2224     paranoid_free(xattr_fname);
    2225     paranoid_free(acl_fname);
    22262147    paranoid_free(tmp);
    2227     paranoid_free(biggies_whose_EXATs_we_should_set);
    22282148    paranoid_free(pathname_of_last_biggie_restored);
    22292149    return (retval);
     
    22582178    char *mds = NULL;
    22592179    char *tmp1 = NULL;
    2260     char *tarball_fname;
    2261     char *progress_str;
     2180    char *tarball_fname = NULL;
     2181    char *progress_str = NULL;
    22622182    char *comment;
    22632183
    22642184    malloc_string(tmp);
    2265     malloc_string(tarball_fname);
    2266     malloc_string(progress_str);
    22672185    malloc_string(comment);
    22682186
     
    22702188
    22712189    mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
    2272     log_msg(2,
    2273             "Insisting on 1st CD, so that I can have a look at LAST-FILELIST-NUMBER");
     2190    log_msg(2, "Insisting on 1st CD, so that I can have a look at LAST-FILELIST-NUMBER");
    22742191    if (g_current_media_number != 1) {
    22752192        log_msg(3, "OK, that's jacked up.");
     
    22822199
    22832200    mds = media_descriptor_string(bkpinfo->backup_media_type);
    2284     sprintf(progress_str, "Restoring from %s #%d", mds, g_current_media_number);
     2201    mr_asprintf(&progress_str, "Restoring from %s #%d", mds, g_current_media_number);
    22852202
    22862203    log_to_screen(progress_str);
     
    22922209        insist_on_this_cd_number(g_current_media_number);
    22932210        update_progress_form(progress_str);
    2294         sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
    2295                 current_tarball_number);
     2211        mr_free(progress_str);
     2212
     2213        mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", current_tarball_number);
    22962214        if (!does_file_exist(tarball_fname)) {
    2297             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.gz",
    2298                 current_tarball_number);
     2215            mr_free(tarball_fname);
     2216            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.gz", current_tarball_number);
    22992217        }
    23002218        if (!does_file_exist(tarball_fname)) {
    2301             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",
    2302                     current_tarball_number);
     2219            mr_free(tarball_fname);
     2220            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", current_tarball_number);
    23032221        }
    23042222        if (!does_file_exist(tarball_fname)) {
    2305             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.",
    2306                     current_tarball_number);
     2223            mr_free(tarball_fname);
     2224            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.", current_tarball_number);
    23072225        }
    23082226        if (!does_file_exist(tarball_fname)) {
    2309             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",
    2310                     current_tarball_number);
     2227            mr_free(tarball_fname);
     2228            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", current_tarball_number);
    23112229        }
    23122230        if (!does_file_exist(tarball_fname)) {
    2313             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.",
    2314                     current_tarball_number);
     2231            mr_free(tarball_fname);
     2232            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.", current_tarball_number);
    23152233        }
    23162234        if (!does_file_exist(tarball_fname)) {
     
    23182236                log_to_screen
    23192237                    ("No tarballs. Strange. Maybe you only backed up freakin' big files?");
     2238                mr_free(tarball_fname);
    23202239                return (0);
    23212240            }
     
    23272246            }
    23282247            g_current_media_number++;
    2329             sprintf(progress_str, "Restoring from %s #%d",
     2248            mr_asprintf(&progress_str, "Restoring from %s #%d",
    23302249                    media_descriptor_string(bkpinfo->backup_media_type),
    23312250                    g_current_media_number);
    23322251            log_to_screen(progress_str);
    23332252        } else {
    2334             sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
     2253            mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d",
    23352254                    current_tarball_number, mds, g_current_media_number);
    2336 //    log_msg(3, "progress_str = %s", progress_str);
    23372255            for (res = 999, attempts = 0; attempts < 3 && res != 0;
    23382256                 attempts++) {
     
    23642282            g_current_progress++;
    23652283        }
     2284        mr_free(tarball_fname);
    23662285    }
    23672286    mr_free(mds);
     2287    mr_free(progress_str);
    23682288
    23692289    close_progress_form();
     
    23732293        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    23742294    }
    2375     paranoid_free(tarball_fname);
    2376     paranoid_free(progress_str);
    23772295    paranoid_free(comment);
    23782296
     
    24062324  /** malloc add ****/
    24072325    char *tmp;
     2326    char *tmp1;
    24082327    char *biggie_fname;
    24092328    char *biggie_cksum;
    2410     char *xattr_fname;
    2411     char *acl_fname;
     2329    char *xattr_fname = NULL;
     2330    char *acl_fname = NULL;
    24122331    char *p;
    24132332    char *pathname_of_last_biggie_restored;
    2414     char *biggies_whose_EXATs_we_should_set;    // EXtended ATtributes
     2333    char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
    24152334    long long biggie_size;
    24162335    FILE *fbw = NULL;
     
    24192338    malloc_string(biggie_fname);
    24202339    malloc_string(biggie_cksum);
    2421     malloc_string(xattr_fname);
    2422     malloc_string(acl_fname);
    2423     malloc_string(biggies_whose_EXATs_we_should_set);
    24242340    malloc_string(pathname_of_last_biggie_restored);
    24252341    assert(bkpinfo != NULL);
     
    24282344
    24292345    total_slices = atol(tmp);
    2430     sprintf(tmp, "Reassembling large files      ");
    24312346    if (g_getfattr) {
    2432         sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2347        mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    24332348    }
    24342349    if (g_getfacl) {
    2435         sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2436     }
    2437     mvaddstr_and_log_it(g_currentY, 0, tmp);
    2438     sprintf(biggies_whose_EXATs_we_should_set,
    2439             "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
     2350        mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2351    }
     2352    mr_asprintf(&tmp1, "Reassembling large files      ");
     2353    mvaddstr_and_log_it(g_currentY, 0, tmp1);
     2354    mr_free(tmp1);
     2355
     2356    mr_asprintf(&biggies_whose_EXATs_we_should_set, "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    24402357    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
    2441         log_msg(1, "Warning - cannot openout %s",
    2442                 biggies_whose_EXATs_we_should_set);
    2443     }
    2444 // get xattr and acl files if they're there
    2445     res =
    2446         read_header_block_from_stream(&biggie_size, biggie_fname,
    2447                                       &ctrl_chr);
     2358        log_msg(1, "Warning - cannot openout %s", biggies_whose_EXATs_we_should_set);
     2359    }
     2360
     2361    // get xattr and acl files if they're there
     2362    res = read_header_block_from_stream(&biggie_size, biggie_fname, &ctrl_chr);
    24482363    if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    24492364        res =
    2450             read_EXAT_files_from_tape(&biggie_size, biggie_fname,
    2451                                       &ctrl_chr, xattr_fname, acl_fname);
     2365            read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname);
    24522366    }
    24532367
    24542368    noof_biggiefiles = atol(biggie_fname);
    2455     sprintf(tmp, "OK, there are %ld biggiefiles in the archives",
    2456             noof_biggiefiles);
    2457     log_msg(2, tmp);
     2369    log_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles);
    24582370    open_progress_form("Reassembling large files",
    24592371                       "I am now reassembling all the large files.",
     
    24782390            p++;
    24792391        }
    2480         sprintf(tmp, "Restoring big file %ld (%lld K)",
     2392        mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)",
    24812393                current_bigfile_number + 1, biggie_size / 1024);
    2482         update_progress_form(tmp);
     2394        update_progress_form(tmp1);
     2395        mr_free(tmp1);
    24832396        res = restore_a_biggiefile_from_stream(biggie_fname,
    24842397                                               current_bigfile_number,
     
    24982411    if (current_bigfile_number != noof_biggiefiles
    24992412        && noof_biggiefiles != 0) {
    2500         sprintf(tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",
    2501                 current_bigfile_number, noof_biggiefiles);
     2413        log_msg(1, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", current_bigfile_number, noof_biggiefiles);
    25022414    } else {
    2503         sprintf(tmp,
    2504                 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.",
    2505                 noof_biggiefiles, current_bigfile_number);
    2506     }
    2507     log_msg(1, tmp);
     2415        log_msg(1, "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", noof_biggiefiles, current_bigfile_number);
     2416    }
    25082417
    25092418    if (fbw) {
     
    25132422            if (g_getfattr) {
    25142423                if (length_of_file(xattr_fname) > 0) {
    2515                     log_msg(1, "set_fattr_List(%s,%s)",
    2516                         biggies_whose_EXATs_we_should_set, xattr_fname);
    2517                     set_fattr_list(biggies_whose_EXATs_we_should_set,
    2518                                xattr_fname);
     2424                    log_msg(1, "set_fattr_List(%s,%s)", biggies_whose_EXATs_we_should_set, xattr_fname);
     2425                    set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
    25192426                }
    25202427            }
    25212428            if (g_getfacl) {
    25222429                if (length_of_file(acl_fname) > 0) {
    2523                     log_msg(1, "set_acl_list(%s,%s)",
    2524                             biggies_whose_EXATs_we_should_set, acl_fname);
     2430                    log_msg(1, "set_acl_list(%s,%s)", biggies_whose_EXATs_we_should_set, acl_fname);
    25252431                    set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    25262432                }
     
    25302436        }
    25312437    }
     2438    mr_free(xattr_fname);
     2439    mr_free(acl_fname);
     2440    mr_free(biggies_whose_EXATs_we_should_set);
     2441
    25322442    if (does_file_exist("/PAUSE")) {
    25332443        popup_and_OK
     
    25412451        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    25422452    }
    2543     paranoid_free(biggies_whose_EXATs_we_should_set);
    25442453    paranoid_free(pathname_of_last_biggie_restored);
    25452454    paranoid_free(biggie_fname);
    25462455    paranoid_free(biggie_cksum);
    2547     paranoid_free(xattr_fname);
    2548     paranoid_free(acl_fname);
    25492456    paranoid_free(tmp);
    25502457    return (retval);
     
    25802487
    25812488  /** malloc **/
    2582     char *tmp;
     2489    char *tmp = NULL;
    25832490    char *mds = NULL;
    2584     char *progress_str;
     2491    char *progress_str = NULL;
    25852492    char *tmp_fname;
    2586     char *xattr_fname;
    2587     char *acl_fname;
     2493    char *xattr_fname = NULL;
     2494    char *acl_fname = NULL;
    25882495
    25892496    long long tmp_size;
    25902497
    2591     malloc_string(tmp);
    2592     malloc_string(progress_str);
    25932498    malloc_string(tmp_fname);
    25942499    assert(bkpinfo != NULL);
    2595     malloc_string(xattr_fname);
    2596     malloc_string(acl_fname);
    25972500    mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
    25982501    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
     
    26032506    run_program_and_log_output("pwd", 5);
    26042507
    2605     sprintf(progress_str, "Restoring from media #%d",
    2606             g_current_media_number);
     2508    mr_asprintf(&progress_str, "Restoring from media #%d", g_current_media_number);
    26072509    log_to_screen(progress_str);
    26082510    open_progress_form("Restoring from archives",
     
    26262528        update_progress_form(progress_str);
    26272529        if (g_getfattr) {
    2628             sprintf(xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
     2530            mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
    26292531                current_afioball_number);
    26302532            unlink(xattr_fname);
    26312533        }
    26322534        if (g_getfacl) {
    2633             sprintf(acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,
    2634                 current_afioball_number);
     2535            mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number);
    26352536            unlink(acl_fname);
    26362537        }
    26372538        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    26382539            log_it("Reading EXAT files from tape");
    2639             res =
    2640                 read_EXAT_files_from_tape(&tmp_size, tmp_fname,
    2641                                           &ctrl_chr, xattr_fname,
    2642                                           acl_fname);
     2540            res = read_EXAT_files_from_tape(&tmp_size, tmp_fname, &ctrl_chr, xattr_fname, acl_fname);
    26432541        }
    26442542        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    26452543            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    26462544        }
    2647         sprintf(tmp,
    2648                 "Restoring from fileset #%ld (name=%s, size=%ld K)",
    2649                 current_afioball_number, tmp_fname, (long) tmp_size >> 10);
    2650         res =
    2651             restore_a_tarball_from_stream(tmp_fname,
    2652                                           current_afioball_number,
    2653                                           filelist, tmp_size, xattr_fname,
    2654                                           acl_fname);
     2545        log_msg(4, "Restoring from fileset #%ld (name=%s, size=%ld K)", current_afioball_number, tmp_fname, (long) tmp_size >> 10);
     2546        res = restore_a_tarball_from_stream(tmp_fname, current_afioball_number, filelist, tmp_size, xattr_fname, acl_fname);
    26552547        retval += res;
    26562548        if (res) {
    2657             sprintf(tmp, "Fileset %ld - errors occurred",
    2658                     current_afioball_number);
     2549            mr_asprintf(&tmp, "Fileset %ld - errors occurred", current_afioball_number);
    26592550            log_to_screen(tmp);
     2551            mr_free(tmp);
    26602552        }
    26612553        res =
     
    26682560        g_current_progress++;
    26692561        mds = media_descriptor_string(bkpinfo->backup_media_type),
    2670         sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
    2671                 current_afioball_number, mds,
    2672                 g_current_media_number);
     2562
     2563        mr_free(progress_str);
     2564        mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", current_afioball_number, mds, g_current_media_number);
    26732565        mr_free(mds);
    2674         res =
    2675             read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
     2566        res = read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
    26762567        if (g_getfattr) {
    26772568            unlink(xattr_fname);
     
    26812572        }
    26822573    }                           // next
     2574    mr_free(progress_str);
     2575    if (g_getfattr) {
     2576        mr_free(xattr_fname);
     2577    }
     2578    if (g_getfacl) {
     2579        mr_free(acl_fname);
     2580    }
     2581
    26832582    log_msg(1, "All done with afioballs");
    26842583    close_progress_form();
     
    26882587        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    26892588    }
    2690     paranoid_free(tmp);
    2691     paranoid_free(progress_str);
    26922589    paranoid_free(tmp_fname);
    2693     paranoid_free(xattr_fname);
    2694     paranoid_free(acl_fname);
    26952590    return (retval);
    26962591}
     
    27192614    char *cwd;
    27202615    char *newpath;
    2721     char *tmp;
     2616    char *tmp = NULL;
    27222617    assert(bkpinfo != NULL);
    27232618
    27242619    malloc_string(cwd);
    27252620    malloc_string(newpath);
    2726     malloc_string(tmp);
    27272621    log_msg(2, "restore_everything() --- starting");
    27282622    g_current_media_number = 1;
    27292623    getcwd(cwd, MAX_STR_LEN - 1);
    2730     sprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
     2624    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);
    27312625    run_program_and_log_output(tmp, FALSE);
     2626    mr_free(tmp);
     2627
    27322628    log_msg(1, "Changing dir to %s", bkpinfo->restore_path);
    27332629    chdir(bkpinfo->restore_path);
     
    27782674    paranoid_free(cwd);
    27792675    paranoid_free(newpath);
    2780     paranoid_free(tmp);
    27812676    return (resA + resB);
    27822677}
     
    28412736    int retval = 0;
    28422737    int res;
    2843 //  int c;
    2844     char *tmp;
     2738    char *tmp = NULL;
    28452739
    28462740    struct mountlist_itself *mountlist;
     
    28612755
    28622756    g_loglevel = DEFAULT_MR_LOGLEVEL;
    2863     malloc_string(tmp);
    28642757
    28652758/* Configure global variables */
     
    28902783    strcpy(g_mondo_home,
    28912784           call_program_and_get_last_line_of_output("which mondorestore"));
    2892     /*
    2893     sprintf(g_tmpfs_mountpt, "/tmp/tmpfs");
    2894     make_hole_for_dir(g_tmpfs_mountpt);
    2895     */
    28962785    g_current_media_number = 1; // precaution
    28972786
     
    29202809
    29212810    /* Backup original mountlist.txt */
    2922     sprintf(tmp, "%s.orig", g_mountlist_fname);
     2811    mr_asprintf(&tmp, "%s.orig", g_mountlist_fname);
    29232812    if (!does_file_exist(g_mountlist_fname)) {
    29242813        log_msg(2,
     
    29262815                __LINE__, g_mountlist_fname);
    29272816    } else if (!does_file_exist(tmp)) {
    2928         sprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname,
    2929                 g_mountlist_fname);
     2817        mr_free(tmp);
     2818        mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname, g_mountlist_fname);
    29302819        run_program_and_log_output(tmp, FALSE);
    29312820    }
     2821    mr_free(tmp);
    29322822
    29332823    /* Init directories */
     
    29822872    }
    29832873
    2984     if (argc >= 2 && strcmp(argv[1], "--pih") == 0) {
    2985         if (system("mount | grep cdrom 2> /dev/null > /dev/null")) {
    2986             system("mount " MNT_CDROM);
    2987         }
    2988         bkpinfo->compression_level = 1;
    2989         g_current_media_number = 2;
    2990         strcpy(bkpinfo->restore_path, "/tmp/TESTING");
    2991         bkpinfo->backup_media_type = dvd;
    2992         open_progress_form("Reassembling /dev/hda1",
    2993                            "Shark is a bit of a silly person.",
    2994                            "Please wait. This may take some time.",
    2995                            "", 1999);
    2996         system("rm -Rf /tmp/*pih*");
    2997 
    2998         restore_a_biggiefile_from_CD(42, NULL, tmp);
    2999     }
    3000 
    30012874    if (argc == 5 && strcmp(argv[1], "--common") == 0) {
    30022875        g_loglevel = 6;
     
    30092882        // BERLIOS: /usr/lib ???
    30102883        toggle_path_selection(filelist, "/usr/share", TRUE);
    3011 //      show_filelist(filelist);
    30122884        save_filelist(filelist, "/tmp/out.txt");
    3013 //      finish(0);
    3014 //      toggle_path_selection (filelist, "/root/stuff", TRUE);
    30152885        strcpy(a, argv[3]);
    30162886        strcpy(b, argv[4]);
     
    31242994        log_msg(2, "Still here. Yay.");
    31252995        if ((strlen(bkpinfo->tmpdir) > 0) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    3126             sprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
     2996            mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
    31272997            run_program_and_log_output(tmp, FALSE);
     2998            mr_free(tmp);
    31282999        }
    31293000        unmount_boot_if_necessary();    /* for Gentoo users */
     
    31483019                sprintf(bkpinfo->isodir, "/tmp/isodir");
    31493020                run_program_and_log_output("mkdir -p /tmp/isodir", 5);
    3150                 sprintf(tmp, "mount %s -t nfs -o nolock,ro /tmp/isodir",
    3151                         bkpinfo->nfs_mount);
     3021                mr_asprintf(&tmp, "mount %s -t nfs -o nolock,ro /tmp/isodir", bkpinfo->nfs_mount);
    31523022                run_program_and_log_output(tmp, 1);
     3023                mr_free(tmp);
    31533024            }
    31543025        }
     
    32453116      } else {
    32463117        log_msg(1, "Re-mounted partitions for post-nuke stuff");
    3247         sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,
    3248             retval);
     3118        mr_asprintf(&tmp, "post-nuke %s %d", bkpinfo->restore_path, retval);
    32493119        log_msg(2, "Calling '%s'", tmp);
    32503120        if ((res = run_program_and_log_output(tmp, 0))) {
    32513121          log_OS_error(tmp);
    32523122        }
     3123        mr_free(tmp);
    32533124        log_msg(1, "post-nuke returned w/ res=%d", res);
    32543125      }
     
    32663137    set_signals(FALSE);
    32673138    log_to_screen("Restore log (%s) copied to /var/log on your hard disk", MONDO_LOGFILE);
    3268     sprintf(tmp,
    3269             "Mondo-restore is exiting (retval=%d)                                      ",
    3270             retval);
     3139    mr_asprintf(&tmp, "Mondo-restore is exiting (retval=%d)                                      ", retval);
    32713140    log_to_screen(tmp);
    3272     sprintf(tmp, "umount %s", bkpinfo->isodir);
     3141    mr_free(tmp);
     3142
     3143    mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    32733144    run_program_and_log_output(tmp, 5);
     3145    mr_free(tmp);
     3146
    32743147    paranoid_free(mountlist);
    32753148    paranoid_free(raidlist);
     
    32783151    }                           // for b0rken distros
    32793152    if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
    3280         sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
     3153        mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);
    32813154        system(tmp);
     3155        mr_free(tmp);
    32823156    }
    32833157    paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
     
    32853159    paranoid_free(a);
    32863160    paranoid_free(b);
    3287     paranoid_free(tmp);
    32883161
    32893162    unlink("/tmp/filelist.full");
Note: See TracChangeset for help on using the changeset viewer.