Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/common


Ignore:
Timestamp:
Jun 3, 2009, 7:10:19 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3089@localhost: bruno | 2009-05-18 06:41:05 +0200

  • move call to asprintf to call to mr_asprintf (suppress a compiler warning)
  • remove all the most obvious bad call to strcat and replace by mr_strcat as appropriate
Location:
branches/2.2.9/mondo/src/common
Files:
11 edited

Legend:

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

    r2202 r2211  
    1212
    1313#include "my-stuff.h"
     14#include "mr_mem.h"
    1415#include "mondostructures.h"
    1516#include "libmondo-string-EXT.h"
     
    192193    unsigned int res = 0;
    193194    int tries = 0;
    194     char *command;
    195     char *zipparams;
    196     char *tmp;
     195    char *command = NULL;
     196    char *tmp = NULL;
    197197    char *p;
    198198
    199     malloc_string(command);
    200     malloc_string(zipparams);
    201     malloc_string(tmp);
    202199
    203200    if (!does_file_exist(filelist)) {
    204         sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
    205                 filelist);
     201        mr_asprintf(&tmp, "(archive_this_fileset) - filelist %s does not exist", filelist);
    206202        log_to_screen(tmp);
     203        paranoid_free(tmp);
    207204        return (1);
    208205    }
    209206
    210     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     207    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    211208    if (system(tmp)) {
     209        paranoid_free(tmp);
    212210        fatal_error("Unable to write tarball to scratchdir");
    213211    }
    214 
    215     sprintf(command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
     212    paranoid_free(tmp);
     213
     214    mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
    216215            filelist, fname);
    217216    if (bkpinfo->use_lzo) {
     
    219218    }
    220219    if (bkpinfo->compression_level > 0) {
    221         strcat(command, " -bz");
    222     }
    223     sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);
     220        mr_strcat(command, " -bz");
     221    }
     222    mr_strcat(command, " 2>> %s", MONDO_LOGFILE);
    224223    log_msg(4, "command = '%s'", command);
    225224
     
    227226        log_msg(5, "command='%s'", command);
    228227        res = system(command);
    229         strcpy(tmp, last_line_of_file(MONDO_LOGFILE));
     228        mr_asprintf(&tmp, last_line_of_file(MONDO_LOGFILE));
    230229        log_msg(1, "res=%d; tmp='%s'", res, tmp);
    231230        if (bkpinfo->use_star && (res == 254 || res == 65024)
     
    235234            res = 0;
    236235        }
     236        paranoid_free(tmp);
     237
    237238        if (res) {
    238239            log_OS_error(command);
     
    249250        }
    250251    }
     252    paranoid_free(command);
     253
    251254    retval += res;
    252255    if (retval) {
     
    256259                tries);
    257260    }
    258 
    259     paranoid_free(command);
    260     paranoid_free(zipparams);
    261     paranoid_free(tmp);
    262261    return (retval);
    263262}
     
    294293
    295294    /*@ buffers ************************************************************ */
    296     char *command;
    297     char *zipparams;
    298     char *tmp;
     295    char *command = NULL;
     296    char *zipparams = NULL;
     297    char *tmp = NULL;
    299298
    300299    assert(bkpinfo != NULL);
     
    306305    }
    307306
    308     malloc_string(command);
    309     malloc_string(zipparams);
    310     malloc_string(tmp);
    311 
    312307    if (!does_file_exist(filelist)) {
    313         sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
     308        mr_asprintf(&tmp, "(archive_this_fileset) - filelist %s does not exist",
    314309                filelist);
    315310        log_to_screen(tmp);
     311        paranoid_free(tmp);
    316312        return (1);
    317313    }
    318     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     314    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    319315    if (system(tmp)) {
     316        paranoid_free(tmp);
    320317        fatal_error("Unable to write tarball to scratchdir");
    321318    }
     319    paranoid_free(tmp);
    322320
    323321
    324322    if (bkpinfo->compression_level > 0) {
    325         sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
     323        mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    326324        //       -b %ld, TAPE_BLOCK_SIZE
    327         sprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
     325        mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    328326                bkpinfo->compression_level);
    329327        if (does_file_exist(tmp)) {
    330             strcat(zipparams, " -E ");
    331             strcat(zipparams, tmp);
     328            mr_strcat(zipparams, " -E %s",tmp);
    332329        } else {
    333330            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    334331        }
     332        paranoid_free(tmp);
    335333    } else {
    336         zipparams[0] = '\0';
     334        mr_asprintf(&zipparams, "");
    337335    }
    338336
     
    347345        fatal_error("scratchdir not found");
    348346    }
    349     sprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
     347    mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    350348            fname, bkpinfo->zip_suffix);
    351349    paranoid_system(command);
    352 
    353     sprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
     350    paranoid_free(command);
     351
     352    mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    354353            TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    355 
    356     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     354    paranoid_free(zipparams);
     355
     356    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    357357    if (system(tmp)) {
     358        paranoid_free(tmp);
    358359        fatal_error("Unable to write tarball to scratchdir");
    359360    }
     361    paranoid_free(tmp);
    360362
    361363    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    370372        }
    371373    }
     374    paranoid_free(command);
     375
    372376    retval += res;
    373377    if (retval) {
     
    378382    }
    379383
    380     paranoid_free(command);
    381     paranoid_free(zipparams);
    382     paranoid_free(tmp);
    383384    return (retval);
    384385}
     
    511512    char *tmp2 = NULL;
    512513    char *scratchdir;
    513     char *command;
     514    char *command = NULL;
    514515    char *use_lzo_sz;
    515516    char *use_gzip_sz;
     
    541542
    542543    assert(bkpinfo != NULL);
    543     command = malloc(1200);
    544544    tmp = malloc(9*MAX_STR_LEN);
    545545    malloc_string(scratchdir);
     
    803803    }
    804804    if (bkpinfo->backup_media_type == usb) {
    805         (void)asprintf(&tmp2, "--usb %s", bkpinfo->media_device);
     805        mr_asprintf(&tmp2, "--usb %s", bkpinfo->media_device);
    806806    } else {
    807         (void)asprintf(&tmp2," ");
     807        mr_asprintf(&tmp2," ");
    808808    }
    809809
     
    828828
    829829    if (g_getfattr) {
    830         (void)asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir);
     830        mr_asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir);
    831831        if (write_one_liner_data_file(tmp1, "TRUE")) {
    832832            log_msg(1, "%ld: Unable to write one-liner XATTR",
     
    836836    }
    837837    if (g_getfacl) {
    838         (void)asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir);
     838        mr_asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir);
    839839        if (write_one_liner_data_file(tmp1, "TRUE")) {
    840840            log_msg(1, "%ld: Unable to write one-liner ACL",
     
    844844    }
    845845    if (bkpinfo->use_obdr) {
    846         (void)asprintf(&tmp1, "%s/OBDR", bkpinfo->tmpdir);
     846        mr_asprintf(&tmp1, "%s/OBDR", bkpinfo->tmpdir);
    847847        if (write_one_liner_data_file(tmp1, "TRUE")) {
    848848            log_msg(1, "%ld: Unable to write one-liner OBDR",
     
    855855        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    856856/* add nfs stuff here? */
    857     sprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
     857    mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
    858858    if (system(command)) {
    859859        res++;
    860860        log_OS_error("Unable to make images directory");
    861861    }
     862    paranoid_free(command);
    862863    sprintf(tmp, "BTW, I'm telling Mindi your kernel is '%s'",
    863864            bkpinfo->kernel_path);
     
    865866    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
    866867
    867     sprintf(command,
     868    mr_asprintf(&command,
    868869/*     "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
    8698706=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
     
    891892            use_gzip_sz);       // parameter #20 (STRING)
    892893
    893 // Watch it! This next line adds a parameter...
    894894    if (bkpinfo->nonbootable_backup) {
    895         strcat(command, " NONBOOTABLE");
     895        mr_strcat(command, " NONBOOTABLE");
    896896    }
    897897    log_msg(2, command);
     
    899899//  popup_and_OK("Pausing");
    900900
    901     res =
    902         run_program_and_log_to_screen(command,
    903                                       "Generating boot+data disks");
     901    res = run_program_and_log_to_screen(command, "Generating boot+data disks");
     902    paranoid_free(command);
     903
    904904    if (bkpinfo->nonbootable_backup) {
    905905        res = 0;
     
    907907    if (!res) {
    908908        log_to_screen("Boot+data disks were created OK");
    909         sprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
     909        mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
    910910                bkpinfo->scratchdir, MINDI_CACHE);
    911911        log_msg(2, command);
    912912        run_program_and_log_output(command, FALSE);
     913        paranoid_free(command);
     914
    913915        if (bkpinfo->nonbootable_backup) {
    914             sprintf(command, "cp -f %s/all.tar.gz %s/images",
     916            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    915917                    bkpinfo->tmpdir, bkpinfo->scratchdir);
    916918            if (system(command)) {
     919                paranoid_free(command);
    917920                fatal_error("Unable to create temporary all tarball");
    918921            }
     922            paranoid_free(command);
    919923        }
    920924        /* For USB we already have everything on the key */
    921925        if (bkpinfo->backup_media_type == usb) {
    922             sprintf(command, "rm -rf %s/images", bkpinfo->scratchdir);
     926            mr_asprintf(&command, "rm -rf %s/images", bkpinfo->scratchdir);
    923927            run_program_and_log_output(command, FALSE);
     928            paranoid_free(command);
    924929        } else {
    925930            sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
     
    936941    } else {
    937942        log_to_screen("Mindi failed to create your boot+data disks.");
    938         strcpy(command, "grep 'Fatal error' /var/log/mindi.log");
     943        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
    939944        strcpy(tmp, call_program_and_get_last_line_of_output(command));
     945        paranoid_free(command);
     946
    940947        if (strlen(tmp) > 1) {
    941948            popup_and_OK(tmp);
     
    957964    paranoid_free(value);
    958965    paranoid_free(bootdev);
    959     paranoid_free(command);
    960966    paranoid_free(use_star_sz);
    961967    return (res);
     
    13451351    char *storing_filelist_fname;
    13461352    char *storing_afioball_fname;
    1347     char *tmp;
     1353    char *tmp = NULL;
    13481354    char *media_usage_comment;
    13491355    pthread_t archival_thread[ARCH_THREADS];
     
    13601366    log_msg(8, "here");
    13611367    assert(bkpinfo != NULL);
    1362     tmp = malloc(MAX_STR_LEN * 2);
    13631368    malloc_string(result_str);
    13641369    malloc_string(curr_xattr_list_fname);
     
    13821387    *p_last_set_archived = -1;
    13831388    *p_next_set_to_archive = 0;
    1384     sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
    13851389    log_to_screen("Archiving regular files");
    13861390    log_msg(5, "Go, Shorty. It's your birthday.");
     
    15001504            update_progress_form(media_usage_comment);
    15011505            if (res) {
    1502                 sprintf(tmp,
     1506                mr_asprintf(&tmp,
    15031507                        "Failed to add archive %ld's files to CD dir\n",
    15041508                        storing_set_no);
    15051509                log_to_screen(tmp);
     1510                paranoid_free(tmp);
    15061511                fatal_error
    15071512                    ("Is your hard disk full? If not, please send the author the logfile.");
     
    15131518    close_progress_form();
    15141519
    1515     sprintf(tmp, "Your regular files have been archived ");
     1520    mr_asprintf(&tmp, "Your regular files have been archived ");
    15161521    log_msg(2, "Joining background threads to foreground thread");
    15171522    for (i = 0; i < noof_threads; i++) {
     
    15221527    log_msg(2, "Done.");
    15231528    if (retval) {
    1524         strcat(tmp, "(with errors).");
     1529        mr_strcat(tmp, "(with errors).");
    15251530    } else {
    1526         strcat(tmp, "successfully.");
     1531        mr_strcat(tmp, "successfully.");
    15271532    }
    15281533    log_to_screen(tmp);
     1534    paranoid_free(tmp);
     1535
    15291536    paranoid_free(transfer_block);
    15301537    paranoid_free(result_str);
     
    15811588    log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir);
    15821589    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    1583     (void)asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
     1590    mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
    15841591    run_program_and_log_output(tmp, FALSE);
    15851592    paranoid_free(tmp);
    15861593    (void)chdir(bkpinfo->scratchdir);
    15871594
    1588     (void)asprintf(&message_to_screen, "Copying data to make %s #%d",
     1595    mr_asprintf(&message_to_screen, "Copying data to make %s #%d",
    15891596                media_descriptor_string(bkpinfo->backup_media_type),
    15901597                g_current_media_number);
    15911598    log_msg(1, message_to_screen);
    15921599
    1593     (void)asprintf(&tmp1, "%s1", bkpinfo->media_device);
     1600    mr_asprintf(&tmp1, "%s1", bkpinfo->media_device);
    15941601    if (is_this_device_mounted(tmp1)) {
    15951602        log_msg(1, "USB device mounted. Remounting it at the right place");
    1596         (void)asprintf(&tmp, "umount %s", tmp1);
     1603        mr_asprintf(&tmp, "umount %s", tmp1);
    15971604        run_program_and_log_output(tmp, FALSE);
    15981605        paranoid_free(tmp);
     
    16011608
    16021609    log_msg(1, "Mounting USB device.");
    1603     (void)asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir);
    1604     (void)asprintf(&tmp, "mkdir -p %s", tmp1);
     1610    mr_asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir);
     1611    mr_asprintf(&tmp, "mkdir -p %s", tmp1);
    16051612    run_program_and_log_output(tmp, FALSE);
    16061613    paranoid_free(tmp);
    16071614    /* Mindi always create one single parition on the USB dev */
    1608     (void)asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
     1615    mr_asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
    16091616    run_program_and_log_output(tmp, FALSE);
    16101617    paranoid_free(tmp);
     
    16161623
    16171624        /* Command to execute */
    1618         (void)asprintf(&tmp,"mv %s/* %s", bkpinfo->scratchdir, tmp1);
     1625        mr_asprintf(&tmp,"mv %s/* %s", bkpinfo->scratchdir, tmp1);
    16191626        res = eval_call_to_make_USB(tmp, message_to_screen);
    16201627        if (res) {
    1621             (void)asprintf(&result_sz, "%s ...failed",tmp);
     1628            mr_asprintf(&result_sz, "%s ...failed",tmp);
    16221629        } else {
    1623             (void)asprintf(&result_sz, "%s ...OK",tmp);
     1630            mr_asprintf(&result_sz, "%s ...OK",tmp);
    16241631        }
    16251632        log_to_screen(result_sz);
     
    16321639
    16331640    if (is_this_device_mounted(bkpinfo->media_device)) {
    1634         (void)asprintf(&tmp, "umount %s1", bkpinfo->media_device);
     1641        mr_asprintf(&tmp, "umount %s1", bkpinfo->media_device);
    16351642        run_program_and_log_output(tmp, FALSE);
    16361643        paranoid_free(tmp);
     
    16721679    char *tmp;
    16731680    char *old_pwd;
    1674     char *result_sz;
    1675     char *message_to_screen;
     1681    char *result_sz = NULL;
     1682    char *message_to_screen = NULL;
    16761683    char *sz_blank_disk;
    16771684    char *fnam;
     
    16811688
    16821689    malloc_string(old_pwd);
    1683     malloc_string(result_sz);
    1684     malloc_string(message_to_screen);
    16851690    malloc_string(sz_blank_disk);
    16861691    malloc_string(fnam);
     
    17171722
    17181723    if (bkpinfo->call_before_iso[0] != '\0') {
    1719         sprintf(message_to_screen, "Running pre-ISO call for CD#%d",
     1724        mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
    17201725                g_current_media_number);
    17211726        res =
     
    17241729                                  MONDO_LOGFILE, message_to_screen);
    17251730        if (res) {
    1726             strcat(message_to_screen, "...failed");
     1731            mr_strcat(message_to_screen, "...failed");
    17271732        } else {
    1728             strcat(message_to_screen, "...OK");
     1733            mr_strcat(message_to_screen, "...OK");
    17291734        }
    17301735        log_to_screen(message_to_screen);
     1736        paranoid_free(message_to_screen);
     1737
    17311738        retval += res;
    17321739    }
     
    17351742        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    17361743        sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    1737         sprintf(message_to_screen, "Making an ISO (%s #%d)",
     1744        mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)",
    17381745                media_descriptor_string(bkpinfo->backup_media_type),
    17391746                g_current_media_number);
     
    18301837            }
    18311838        }
     1839        paranoid_free(message_to_screen);
    18321840    } else {
    1833         sprintf(message_to_screen, "Running mkisofs to make %s #%d",
     1841        mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
    18341842                media_descriptor_string(bkpinfo->backup_media_type),
    18351843                g_current_media_number);
    18361844        log_msg(1, message_to_screen);
    1837         sprintf(result_sz, "Call to mkisofs to make ISO (%s #%d) ",
     1845        mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
    18381846                media_descriptor_string(bkpinfo->backup_media_type),
    18391847                g_current_media_number);
     
    18881896            }
    18891897        }
     1898        paranoid_free(message_to_screen);
     1899
    18901900        if (res) {
    1891             strcat(result_sz, "...failed");
     1901            mr_strcat(result_sz, "...failed");
    18921902        } else {
    1893             strcat(result_sz, "...OK");
     1903            mr_strcat(result_sz, "...OK");
    18941904        }
    18951905        log_to_screen(result_sz);
     1906        paranoid_free(result_sz);
    18961907        retval += res;
    18971908    }
     
    19101921    if (bkpinfo->call_burn_iso[0] != '\0') {
    19111922        log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
    1912         sprintf(message_to_screen, "Burning %s #%d",
     1923        mr_asprintf(&message_to_screen, "Burning %s #%d",
    19131924                media_descriptor_string(bkpinfo->backup_media_type),
    19141925                g_current_media_number);
     
    19191930                                  MONDO_LOGFILE, message_to_screen);
    19201931        if (res) {
    1921             strcat(message_to_screen, "...failed");
     1932            mr_strcat(message_to_screen, "...failed");
    19221933        } else {
    1923             strcat(message_to_screen, "...OK");
     1934            mr_strcat(message_to_screen, "...OK");
    19241935        }
    19251936        log_to_screen(message_to_screen);
     1937        paranoid_free(message_to_screen);
     1938
    19261939        retval += res;
    19271940    }
    19281941
    19291942    if (bkpinfo->call_after_iso[0] != '\0') {
    1930         sprintf(message_to_screen, "Running post-ISO call (%s #%d)",
     1943        mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
    19311944                media_descriptor_string(bkpinfo->backup_media_type),
    19321945                g_current_media_number);
     
    19361949                                  MONDO_LOGFILE, message_to_screen);
    19371950        if (res) {
    1938             strcat(message_to_screen, "...failed");
     1951            mr_strcat(message_to_screen, "...failed");
    19391952        } else {
    1940             strcat(message_to_screen, "...OK");
     1953            mr_strcat(message_to_screen, "...OK");
    19411954        }
    19421955        log_to_screen(message_to_screen);
     1956        paranoid_free(message_to_screen);
     1957
    19431958        retval += res;
    19441959    }
     
    19491964    }
    19501965    paranoid_free(old_pwd);
    1951     paranoid_free(result_sz);
    1952     paranoid_free(message_to_screen);
    19531966    paranoid_free(sz_blank_disk);
    19541967    paranoid_free(fnam);
     
    20102023
    20112024    /*@ buffers ******************************************** */
    2012     char *tmp;
     2025    char *tmp = NULL;
    20132026    char *bigfile_fname;
    20142027    char *sz_devfile;
     
    20312044    assert_string_is_neither_NULL_nor_zerolength(biggielist_fname);
    20322045
    2033     malloc_string(tmp);
    20342046    malloc_string(bigfile_fname);
    20352047    malloc_string(sz_devfile);
     
    20472059        return (0);
    20482060    }
    2049     sprintf(tmp, "I am now backing up all large files.");
     2061    mr_asprintf(&tmp, "I am now backing up all large files.");
    20502062    log_to_screen(tmp);
    20512063    noof_biggie_files = count_lines_in_file(biggielist_fname);
     
    20532065                       "Please wait. This may take some time.", "",
    20542066                       estimated_total_noof_slices);
     2067    paranoid_free(tmp);
     2068
    20552069    if (!(fin = fopen(biggielist_fname, "r"))) {
    20562070        log_OS_error("Unable to openin biggielist");
     
    21092123                }
    21102124            }
    2111 // Otherwise, use good old 'dd' and 'bzip2'
     2125            // Otherwise, use good old 'dd' and 'bzip2'
    21122126            else {
    21132127                sz_devfile[0] = '\0';
     
    21152129            }
    21162130
    2117 // Whether partition or biggiefile, just do your thang :-)
    2118             sprintf(tmp, "Bigfile #%ld is '%s' (%ld KB)",
    2119                     biggie_file_number + 1, bigfile_fname,
    2120                     (long) biggie_fsize >> 10);
     2131            // Whether partition or biggiefile, just do your thang :-)
    21212132            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    21222133                write_header_block_to_stream(biggie_fsize, bigfile_fname,
     
    21422153                p = bigfile_fname;
    21432154            }
    2144             sprintf(tmp, "Archiving %s ... ", bigfile_fname);
     2155            mr_asprintf(&tmp, "Archiving %s ... ", bigfile_fname);
    21452156            if (res) {
    2146                 strcat(tmp, "Failed!");
     2157                mr_strcat(tmp, "Failed!");
    21472158            } else {
    2148                 strcat(tmp, "OK");
     2159                mr_strcat(tmp, "OK");
    21492160            }
    21502161            if (delete_when_done) {
     
    21592170        }
    21602171#endif
     2172        paranoid_free(tmp);
    21612173    }
    21622174    log_msg(1, "Finished backing up bigfiles");
     
    21652177    close_progress_form();
    21662178    paranoid_fclose(fin);
    2167     paranoid_free(tmp);
    21682179    paranoid_free(bigfile_fname);
    21692180    paranoid_free(sz_devfile);
     
    21912202    char *curr_xattr_list_fname;
    21922203    char *curr_acl_list_fname;
    2193     char *tmp;
     2204    char *tmp = NULL;
    21942205    char *media_usage_comment;
    21952206
     
    21992210    malloc_string(curr_xattr_list_fname);
    22002211    malloc_string(curr_acl_list_fname);
    2201 
    2202     tmp = malloc(MAX_STR_LEN * 2);
    2203 
    2204     sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
    22052212
    22062213    log_to_screen("Archiving regular files");
     
    22422249        retval += res;
    22432250        if (res) {
    2244             sprintf(tmp,
     2251            mr_asprintf(&tmp,
    22452252                    "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
    22462253                    curr_set_no);
    22472254            log_to_screen(tmp);
     2255            paranoid_free(tmp);
    22482256        }
    22492257
     
    22882296
    22892297        if (res) {
    2290             sprintf(tmp, "Failed to add archive %ld's files to CD dir\n",
     2298            mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    22912299                    curr_set_no);
    22922300            log_to_screen(tmp);
     2301            paranoid_free(tmp);
    22932302            fatal_error
    22942303                ("Is your hard disk is full? If not, please send the author the logfile.");
     
    22962305    }
    22972306    close_progress_form();
    2298     sprintf(tmp, "Your regular files have been archived ");
     2307    mr_asprintf(&tmp, "Your regular files have been archived ");
    22992308    if (retval) {
    2300         strcat(tmp, "(with errors).");
     2309        mr_strcat(tmp, "(with errors).");
    23012310    } else {
    2302         strcat(tmp, "successfully.");
     2311        mr_strcat(tmp, "successfully.");
    23032312    }
    23042313    log_to_screen(tmp);
     
    23982407    }
    23992408
    2400     (void)asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
     2409    mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    24012410            biggielist);
    24022411    paranoid_system(command);
    24032412    paranoid_free(command);
    24042413
    2405     (void)asprintf(&blah, "biggielist = %s", biggielist);
     2414    mr_asprintf(&blah, "biggielist = %s", biggielist);
    24062415    log_msg(2, blah);
    24072416    paranoid_free(blah);
     
    24132422    if (g_getfattr) {
    24142423        get_fattr_list(biggielist, xattr_fname);
    2415         (void)asprintf(&command, "cp %s %s/archives/", xattr_fname,
     2424        mr_asprintf(&command, "cp %s %s/archives/", xattr_fname,
    24162425            bkpinfo->scratchdir);
    24172426        paranoid_system(command);
     
    24202429    if (g_getfacl) {
    24212430        get_acl_list(biggielist, acl_fname);
    2422         (void)asprintf(&command, "cp %s %s/archives/", acl_fname,
     2431        mr_asprintf(&command, "cp %s %s/archives/", acl_fname,
    24232432             bkpinfo->scratchdir);
    24242433        paranoid_system(command);
     
    24282437    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    24292438        res += write_EXAT_files_to_tape(xattr_fname, acl_fname);
    2430         (void)asprintf(&blah, "%ld", count_lines_in_file(biggielist));
     2439        mr_asprintf(&blah, "%ld", count_lines_in_file(biggielist));
    24312440        write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES);
    24322441        paranoid_free(blah);
     
    29542963
    29552964    /*@ buffers ************************************************** */
    2956     char *tmp, *checksum_line, *command;
     2965    char *tmp = NULL;
     2966    char *checksum_line, *command;
    29572967    char *tempblock;
    29582968    char *curr_slice_fname_uncompressed;
     
    29903000    assert(bkpinfo != NULL);
    29913001    assert_string_is_neither_NULL_nor_zerolength(biggie_filename);
    2992     malloc_string(tmp);
    29933002    malloc_string(checksum_line);
    29943003    malloc_string(curr_slice_fname_uncompressed);
     
    30283037        sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    30293038        log_it("command = %s", command);
    3030         strcpy (tmp, call_program_and_get_last_line_of_output(command));
     3039        mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));
    30313040        log_it("res of it = %s", tmp);
    30323041        totallength = (off_t)atoll(tmp);
     3042        paranoid_free(tmp);
    30333043    } else {
    30343044        file_to_openin = biggie_filename;
     
    30573067    strcpy(biggiestruct.checksum, checksum_line);
    30583068
    3059     strcpy(tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
     3069    mr_asprintf(&tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
    30603070    fout = fopen(tmp, "w");
    30613071    if (fout == NULL) {
     
    30653075        return (1);
    30663076    }
     3077    paranoid_free(tmp);
    30673078
    30683079    (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
     
    30753086    if (!(fin = fopen(file_to_openin, "r"))) {
    30763087        log_OS_error("Unable to openin biggie_filename");
    3077         sprintf(tmp, "Cannot archive bigfile '%s': not found",
    3078                 biggie_filename);
     3088        mr_asprintf(&tmp, "Cannot archive bigfile '%s': not found", biggie_filename);
    30793089        log_to_screen(tmp);
     3090        paranoid_free(tmp);
     3091
    30803092        paranoid_free(tempblock);
    3081         paranoid_free(tmp);
    30823093        paranoid_free(checksum_line);
    30833094        paranoid_free(command);
     
    31023113                           suffix));
    31033114
    3104         strcpy(tmp, percent_media_full_comment());
     3115        mr_asprintf(&tmp, percent_media_full_comment());
    31053116        update_progress_form(tmp);
     3117        paranoid_free(tmp);
     3118
    31063119        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
    31073120            log_OS_error(curr_slice_fname_uncompressed);
     
    31563169            }
    31573170            if (res) {
    3158                 sprintf(tmp, "Problem with slice # %ld", slice_num);
     3171                mr_asprintf(&tmp, "Problem with slice # %ld", slice_num);
    31593172            } else {
    3160                 sprintf(tmp,
     3173                mr_asprintf(&tmp,
    31613174                        "%s - Bigfile #%ld, slice #%ld compressed OK          ",
    31623175                        biggie_filename, biggie_file_number + 1,
     
    31733186            log_msg(2, tmp);
    31743187#endif
     3188            paranoid_free(tmp);
     3189
    31753190            strcpy(file_to_archive, curr_slice_fname_compressed);
    31763191            g_current_progress++;
     
    31953210        retval += res;
    31963211        if (res) {
    3197             sprintf(tmp,
     3212            mr_asprintf(&tmp,
    31983213                    "Failed to add slice %ld of bigfile %ld to scratchdir",
    31993214                    slice_num, biggie_file_number + 1);
    32003215            log_to_screen(tmp);
     3216            paranoid_free(tmp);
    32013217            fatal_error
    32023218                ("Hard disk full. You should have bought a bigger one.");
     
    32043220    }
    32053221    paranoid_fclose(fin);
    3206     sprintf(tmp, "Sliced bigfile #%ld", biggie_file_number + 1);
     3222    mr_asprintf(&tmp, "Sliced bigfile #%ld", biggie_file_number + 1);
    32073223    if (retval) {
    3208         strcat(tmp, "...FAILED");
     3224        mr_strcat(tmp, "...FAILED");
    32093225    } else {
    3210         strcat(tmp, "...OK!");
     3226        mr_strcat(tmp, "...OK!");
    32113227    }
    32123228    log_msg(1, tmp);
     3229    paranoid_free(tmp);
     3230
    32133231    paranoid_free(tempblock);
    3214     paranoid_free(tmp);
    32153232    paranoid_free(checksum_line);
    32163233    paranoid_free(command);
  • branches/2.2.9/mondo/src/common/libmondo-cli.c

    r2202 r2211  
    1212#include <pthread.h>
    1313#include "my-stuff.h"
     14#include "mr_mem.h"
     15#include "mr_string.h"
    1416#include "mondostructures.h"
    1517#include "libmondo-cli-EXT.h"
    1618#include "libmondo.h"
    17 #include "mr_string.h"
    1819
    1920extern int g_loglevel;
     
    278279    ********/
    279280    /* Get the number of mounted file systems ((those that start with "/dev/" */
    280     asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
     281    mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
    281282    log_msg(5, "Running: %s", command);
    282     asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     283    mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    283284    paranoid_free(command);
    284285
     
    288289
    289290    for (i=mount_cnt; i > 0; i--) {
    290         asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
     291        mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
    291292        log_msg(5, "Running: %s", command);
    292         asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     293        mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    293294        paranoid_free(command);
    294295
     
    366367    log_msg(5, "  %s looks like a device special file", dsf);
    367368    /* Verify that the dsf exists */
    368     asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf);
     369    mr_asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf);
    369370    log_msg(5, "  Executing: %s", command);
    370     asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     371    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    371372    paranoid_free(command);
    372373
     
    392393    * Either way, it's an error.
    393394    ********/
    394     asprintf(&command,
     395    mr_asprintf(&command,
    395396      "fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    396397    log_msg(4, "Executing: %s", command);
    397     asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));
     398    mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));
    398399    paranoid_free(command);
    399400    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
     
    445446        log_msg(4, "Processing partition: %s", partitions[i]);
    446447        /* See if it's swap. If it is, ignore it. */
    447         asprintf(&command,
     448        mr_asprintf(&command,
    448449          "fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
    449450          dsf, partitions[i]);
    450451        log_msg(4, "  Running: %s", command);
    451         asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     452        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    452453        paranoid_free(command);
    453454        log_msg(4, "  Return value: %s", tmp);
     
    459460        }
    460461        /* It's not swap. See if we can find the mount point from the mount command. */
    461         asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    462         asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     462        mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
     463        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    463464        paranoid_free(command);
    464465        if (strlen(tmp)) {
     
    477478        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
    478479        /* Get the partition ID; 8e for LVM */
    479         asprintf(&command, "fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
     480        mr_asprintf(&command, "fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
    480481        log_msg(4, "  Running: %s", command);
    481         asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     482        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    482483        paranoid_free(command);
    483484        if (strlen(tmp)) {
     
    486487                /* It's LVM: Find the VG it's in */
    487488                log_msg(4, "  It's LVM: Find the VG it's in...");
    488                 asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
     489                mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    489490                log_msg(4, "  Running: %s", command);
    490491                strcpy(VG, call_program_and_get_last_line_of_output(command));
     
    494495                    /* Found the Volume Group. Now find all of the VG's mount points */
    495496                    log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
    496                     asprintf(&command,
     497                    mr_asprintf(&command,
    497498                      "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'",
    498499                      VG, VG);
    499500                    log_msg(4, "  Running: %s", command);
    500                     asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     501                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    501502                    paranoid_free(command);
    502503                    log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
     
    516517                     *******/
    517518                    paranoid_free(mount_list);
    518                     asprintf(&command, "%s",
     519                    mr_asprintf(&command, "%s",
    519520                        "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    520521                    log_msg (5, "Running: %s", command);
    521                     asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     522                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    522523                    paranoid_free(command);
    523524                    log_msg(4, "  Software raid device list: %s", mount_list);   
    524525                    lastpos = 0;
    525526                    while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    526                         asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
     527                        mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    527528                        log_msg (5, "Running: %s", command);
    528529                        paranoid_free(tmp);
    529                         asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     530                        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    530531                        paranoid_free(command);
    531532                        log_msg(4, "Number of Software raid device: %s", tmp);
     
    557558         ********/
    558559        log_msg (5, "It's not swap, mounted, or LVM. See if it's used in a software raid device.");
    559         asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
     560        mr_asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
    560561        log_msg(4, "  Running: %s", command);
    561         asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     562        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    562563        paranoid_free(command);
    563564        if (!strlen(tmp)) {
     
    568569        log_msg (5, "  UUID: %s", tmp);
    569570        /* Get the Software raid device list */
    570         asprintf(&command, "%s",
     571        mr_asprintf(&command, "%s",
    571572         "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    572573        log_msg (5, "  Running: %s", command);
    573         asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     574        mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    574575        paranoid_free(command);
    575576        log_msg(4, "  Software raid device list: %s", mount_list);   
     
    577578        lastpos = 0;
    578579        while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    579             asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
     580            mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    580581            log_msg(4, "  Running: %s", command);
    581582            paranoid_free(tmp);
    582             asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     583            mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    583584            paranoid_free(command);
    584585            if (!atoi(tmp)) {
     
    756757        }
    757758       
    758         asprintf(&tmp1, "%s", flag_val['I']);
     759        mr_asprintf(&tmp1, "%s", flag_val['I']);
    759760        p = tmp1;
    760761        q = tmp1;
     
    10351036    if (flag_set['z']) {
    10361037        if (find_home_of_exe("getfattr")) {
    1037             asprintf(&g_getfattr,"getfattr");
     1038            mr_asprintf(&g_getfattr,"getfattr");
    10381039        }
    10391040        if (find_home_of_exe("getfacl")) {
    1040             asprintf(&g_getfacl,"getfacl");
     1041            mr_asprintf(&g_getfacl,"getfacl");
    10411042        }
    10421043    }
     
    10551056            strcat(bkpinfo->exclude_paths, " ");
    10561057        }
    1057         asprintf(&tmp1, "%s", flag_val['E']);
     1058        mr_asprintf(&tmp1, "%s", flag_val['E']);
    10581059
    10591060        p = tmp1;
     
    12111212
    12121213    if ((flag_set['n']) && (! bkpinfo->restore_data)) {
    1213         asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir);
     1214        mr_asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir);
    12141215        sprintf(tmp, "echo hi > %s", tmp1);
    12151216        if (run_program_and_log_output(tmp, 2)) {
     
    14671468            if (flag_set[optopt]) {
    14681469                bad_switches = TRUE;
    1469                 (void) asprintf(&tmp, "Switch -%c previously defined as %s\n", opt,
     1470                mr_asprintf(&tmp, "Switch -%c previously defined as %s\n", opt,
    14701471                        flag_val[i]);
    14711472                log_to_screen(tmp);
     
    14841485                        if (strchr(flag_val[opt], '/')
    14851486                            && flag_val[opt][0] != '/') {
    1486                             (void)asprintf(&tmp,
     1487                            mr_asprintf(&tmp,
    14871488                                    "-%c flag --- must be absolute path --- '%s' isn't absolute",
    14881489                                    opt, flag_val[opt]);
     
    14991500    for (i = optind; i < argc; i++) {
    15001501        bad_switches = TRUE;
    1501         (void)asprintf(&tmp, "Invalid arg -- %s\n", argv[i]);
     1502        mr_asprintf(&tmp, "Invalid arg -- %s\n", argv[i]);
    15021503        log_to_screen(tmp);
    15031504        paranoid_free(tmp);
     
    15251526void terminate_daemon(int sig)
    15261527{
    1527     char tmp[64];
    1528     char tmp2[MAX_STR_LEN];
    1529     //  char command[512];
    1530     //  pid_t pid;
     1528    char *tmp = NULL;
     1529    char *tmp2 = NULL;
    15311530
    15321531    switch (sig) {
    15331532    case SIGINT:
    1534         sprintf(tmp, "SIGINT");
    1535         strcpy(tmp2, "You interrupted me :-)");
     1533        mr_asprintf(&tmp, "SIGINT");
     1534        mr_asprintf(&tmp2, "You interrupted me :-)");
    15361535        break;
    15371536    case SIGKILL:
    1538         sprintf(tmp, "SIGKILL");
    1539         strcpy(tmp2,
     1537        mr_asprintf(&tmp, "SIGKILL");
     1538        mr_asprintf(&tmp2,
    15401539               "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
    15411540        break;
    15421541    case SIGTERM:
    1543         sprintf(tmp, "SIGTERM");
    1544         strcpy(tmp2, "Got terminate signal");
     1542        mr_asprintf(&tmp, "SIGTERM");
     1543        mr_asprintf(&tmp2, "Got terminate signal");
    15451544        break;
    15461545    case SIGHUP:
    1547         sprintf(tmp, "SIGHUP");
    1548         strcpy(tmp2, "Hangup on line");
     1546        mr_asprintf(&tmp, "SIGHUP");
     1547        mr_asprintf(&tmp2, "Hangup on line");
    15491548        break;
    15501549    case SIGSEGV:
    1551         sprintf(tmp, "SIGSEGV");
    1552         strcpy(tmp2,
     1550        mr_asprintf(&tmp, "SIGSEGV");
     1551        mr_asprintf(&tmp2,
    15531552               "Internal programming error. Please send a backtrace as well as your log.");
    15541553        break;
    15551554    case SIGPIPE:
    1556         sprintf(tmp, "SIGPIPE");
    1557         strcpy(tmp2, "Pipe was broken");
     1555        mr_asprintf(&tmp, "SIGPIPE");
     1556        mr_asprintf(&tmp2, "Pipe was broken");
    15581557        break;
    15591558    case SIGABRT:
    1560         sprintf(tmp, "SIGABRT");
    1561         sprintf(tmp2,
     1559        mr_asprintf(&tmp, "SIGABRT");
     1560        mr_asprintf(&tmp2,
    15621561                "Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.");
    15631562        break;
    15641563    default:
    1565         sprintf(tmp, "(Unknown)");
    1566     }
    1567 
    1568     strcat(tmp, " signal received from OS");
     1564        mr_asprintf(&tmp, "(Unknown)");
     1565        mr_asprintf(&tmp2, "(Unknown)");
     1566    }
     1567
     1568    mr_strcat(tmp, " signal received from OS");
    15691569    log_to_screen(tmp);
     1570    paranoid_free(tmp);
     1571
    15701572    log_to_screen(tmp2);
     1573    paranoid_free(tmp2);
    15711574    if (sig == SIGABRT) {
    15721575        sleep(10);
  • branches/2.2.9/mondo/src/common/libmondo-devices.c

    r2205 r2211  
    99
    1010#include "my-stuff.h"
     11#include "mr_mem.h"
    1112#include "mondostructures.h"
    1213#include "libmondo-files-EXT.h"
     
    327328    char *program;
    328329    char *incoming;
    329     char *searchstr;
     330    char *searchstr = NULL;
    330331    char *tmp;
    331332
     
    10401041bool is_this_a_valid_disk_format(char *format)
    10411042{
    1042     char *good_formats;
     1043    char *good_formats = NULL;
    10431044    char *command;
    10441045    char *format_sz;
     
    12881289{
    12891290    /*@ buffer ****************************************************** */
    1290     char *command;
    1291     char *dev;
    1292     char *options;
     1291    char *command = NULL;
    12931292    int retval;
    12941293
    1295     malloc_string(command);
    1296     malloc_string(dev);
    1297     malloc_string(options);
    12981294    assert_string_is_neither_NULL_nor_zerolength(device);
    12991295    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    13001296
    13011297    make_hole_for_dir(mountpoint);
    1302     strcpy(options, "ro");
     1298
     1299#ifndef __FreeBSD__
     1300    char *dev = NULL;
     1301    char *options = NULL;
     1302    mr_asprintf(&options, "ro");
     1303#endif
     1304
    13031305    if (isdigit(device[0])) {
    13041306        find_cdrom_device(device, FALSE);
    1305     } else {
    1306         strcpy(dev, device);
    13071307    }
    13081308    if (g_ISO_restore_mode) {
    13091309
    13101310#ifdef __FreeBSD__
    1311         strcpy(dev, make_vn(device));
     1311        mr_asprintf(&dev, make_vn(device));
    13121312        if (!dev) {
    1313             sprintf(command, "Unable to mount ISO (make_vn(%s) failed)",
    1314                     device);
     1313            mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)", device);
    13151314            fatal_error(command);
    13161315        }
    13171316        strcpy(device, dev);
     1317        paranoid_free(dev);
    13181318#else
    1319         strcat(options, ",loop");
     1319        mr_strcat(options, ",loop");
    13201320#endif
    13211321
     
    13261326
    13271327#ifdef __FreeBSD__
    1328     sprintf(command, "mount_cd9660 -r %s %s 2>> %s",
     1328    mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s",
    13291329            device, mountpoint, MONDO_LOGFILE);
    13301330
    13311331#else
    1332     sprintf(command, "mount %s -o %s -t iso9660 %s 2>> %s",
     1332    mr_asprintf(&command, "mount %s -o %s -t iso9660 %s 2>> %s",
    13331333            device, options, mountpoint, MONDO_LOGFILE);
     1334    paranoid_free(options);
    13341335#endif
    13351336
     
    13401341    retval = system(command);
    13411342    log_msg(1, "system(%s) returned %d", command, retval);
    1342 
    13431343    paranoid_free(command);
    1344     paranoid_free(dev);
    1345     paranoid_free(options);
     1344
    13461345    return (retval);
    13471346}
     
    21832182void sensibly_set_tmpdir_and_scratchdir()
    21842183{
    2185     char *tmp, *command, *sz;
    2186 
    2187     malloc_string(tmp);
     2184    char *tmp = NULL;
     2185    char *command, *sz;
     2186
    21882187    malloc_string(command);
    21892188    malloc_string(sz);
     
    21912190
    21922191#ifdef __FreeBSD__
    2193     strcpy(tmp,
     2192    mr_asprintf(&tmp,
    21942193           call_program_and_get_last_line_of_output
    21952194           ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    21962195#else
    2197     strcpy(tmp,
     2196    mr_asprintf(&tmp,
    21982197           call_program_and_get_last_line_of_output
    21992198           ("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     
    22022201    if (tmp[0] != '/') {
    22032202        strcpy(sz, tmp);
    2204         strcpy(tmp, "/");
    2205         strcat(tmp, sz);
     2203        paranoid_free(tmp);
     2204        mr_asprintf(&tmp, "/%s", sz);
    22062205    }
    22072206    if (!tmp[0]) {
     
    22162215
    22172216    sprintf(command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);
     2217    paranoid_free(tmp);
     2218
    22182219    paranoid_system(command);
    2219     paranoid_free(tmp);
    22202220    paranoid_free(command);
    22212221    paranoid_free(sz);
     
    22822282{
    22832283    int cd_number = -1;
    2284     char *mountdev;
    2285     char *tmp;
    2286 
    2287     malloc_string(mountdev);
    2288     malloc_string(tmp);
     2284    char *mountdev = NULL;
     2285    char *tmp = NULL;
     2286
    22892287    assert(bkpinfo != NULL);
    22902288//  log_it("Asking what_number_cd_is_this");
    22912289    if (g_ISO_restore_mode) {
    2292         sprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'");
    2293 //      log_it("tmp = %s", tmp);
    2294 
    2295         strcpy(mountdev, call_program_and_get_last_line_of_output(tmp));
    2296         strcat(mountdev, "/archives/THIS-CD-NUMBER");
    2297 //      log_it("mountdev = %s", mountdev);
     2290        mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'");
     2291
     2292        mr_asprintf(&mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
    22982293        cd_number = atoi(last_line_of_file(mountdev));
    2299 //      log_it("cd_number = %d", cd_number);
    23002294        paranoid_free(mountdev);
    23012295        paranoid_free(tmp);
     2296
    23022297        return (cd_number);
    23032298    }
    23042299
    2305     strcpy(mountdev, bkpinfo->media_device);
     2300    mr_asprintf(&mountdev, bkpinfo->media_device);
    23062301    if (!mountdev[0]) {
    23072302        log_it
     
    23162311        }
    23172312    }
    2318     cd_number =
    2319         atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
    2320 //  log_it("cd_number..later.. = %d", cd_number);
    23212313    paranoid_free(mountdev);
    2322     paranoid_free(tmp);
     2314
     2315    cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
    23232316    return (cd_number);
    23242317}
  • branches/2.2.9/mondo/src/common/libmondo-filelist.c

    r2206 r2211  
    1818#include "libmondo-tools-EXT.h"
    1919#include "mr_string.h"
     20#include "mr_mem.h"
    2021
    2122#include <time.h>
     
    484485        log_msg(8, "Analyzing %s", file_to_analyze);
    485486        tmp = mr_stresc(file_to_analyze, "`$\\\"(){}[]'*?&|!#~", '\\');
    486         (void)asprintf(&strtmp, syscall_sprintf, tmp);
     487        mr_asprintf(&strtmp, syscall_sprintf, tmp);
    487488        paranoid_free(tmp);
    488         (void)asprintf(&syscall, "%s 2>> /dev/null", strtmp);   // " MONDO_LOGFILE);
     489        mr_asprintf(&syscall, "%s 2>> /dev/null", strtmp);  // " MONDO_LOGFILE);
    489490        paranoid_free(strtmp);
    490491        call_exe_and_pipe_output_to_fd(syscall, pout);
     
    13891390        malloc_string(name_of_evalcall_form);
    13901391        malloc_string(find_skeleton_marker);
    1391         (void)asprintf(&find_excludes, " ");
     1392        mr_asprintf(&find_excludes, " ");
    13921393        while((token = mr_strtok (sth, delims, &lastpos))) {
    1393           (void)asprintf(&strtmp,"%s", find_excludes);
     1394          mr_asprintf(&strtmp,"%s", find_excludes);
    13941395          paranoid_free(find_excludes);
    1395           (void)asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
     1396          mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
    13961397          paranoid_free(strtmp);
    13971398          paranoid_free(token);
     
    13991400#if linux
    14001401        // 2.6 has /sys as a proc-type thing -- must be excluded
    1401         (void)asprintf(&strtmp,
     1402        mr_asprintf(&strtmp,
    14021403             "find '%s' -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype proc -prune -o -fstype sysfs -prune -o %s -type d -print > %s 2> /dev/null",
    14031404             dir, find_excludes, g_skeleton_filelist);
    14041405#else
    14051406        // On BSD, for example, /sys is the kernel sources -- don't exclude
    1406         (void)asprintf(&strtmp,
     1407        mr_asprintf(&strtmp,
    14071408             "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null",
    14081409                dir, find_excludes, g_skeleton_filelist);
     
    14121413        (void)system(strtmp);
    14131414        paranoid_free(strtmp);
    1414         (void)asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
     1415        mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    14151416        g_skeleton_entries =
    14161417            1 + atol(call_program_and_get_last_line_of_output(tmp));
     
    14421443#ifndef _XWIN
    14431444                if (!g_text_mode) {
    1444                     (void)asprintf(&tmp, "Reading %-68s", dir);
     1445                    mr_asprintf(&tmp, "Reading %-68s", dir);
    14451446                    newtDrawRootText(0, g_noof_rows - 3, tmp);
    14461447                    paranoid_free(tmp);
     
    14561457//  log_msg(0, "Cataloguing %s", dir);
    14571458    if (sth[0] == ' ') {
    1458         (void)asprintf(&skip_these, "%s", sth);
     1459        mr_asprintf(&skip_these, "%s", sth);
    14591460    } else {
    1460         (void)asprintf(&skip_these, " %s ", sth);
    1461     }
    1462     (void)asprintf(&new_with_spaces, " %s ", dir);
     1461        mr_asprintf(&skip_these, " %s ", sth);
     1462    }
     1463    mr_asprintf(&new_with_spaces, " %s ", dir);
    14631464    if ((dip = opendir(dir)) == NULL) {
    1464         (void)asprintf(&tmp,"opendir %s", dir);
     1465        mr_asprintf(&tmp,"opendir %s", dir);
    14651466        log_OS_error(tmp);
    14661467        paranoid_free(tmp);
     
    14721473            i++;
    14731474            if (strcmp(dir, "/")) {
    1474                 (void)asprintf(&new,"%s/%s",dir,dit->d_name);
     1475                mr_asprintf(&new,"%s/%s",dir,dit->d_name);
    14751476            } else {
    1476                 (void)asprintf(&new,"%s%s",dir,dit->d_name);
     1477                mr_asprintf(&new,"%s%s",dir,dit->d_name);
    14771478            }
    14781479            paranoid_free(new_with_spaces);
    1479             (void)asprintf(&new_with_spaces, " %s ", new);
     1480            mr_asprintf(&new_with_spaces, " %s ", new);
    14801481            if (strstr(skip_these, new_with_spaces)) {
    14811482                fprintf(fout, "%s\n", new);
     
    14961497                                counter = 0;
    14971498                                uberctr++;
    1498                                 (void)asprintf(&tmp, " %c ",
     1499                                mr_asprintf(&tmp, " %c ",
    14991500                                        special_dot_char(uberctr));
    15001501#ifndef _XWIN
     
    15501551    bool in_quotes = FALSE;
    15511552
    1552     (void)asprintf(&sz_res, "%s", incoming);
     1553    mr_asprintf(&sz_res, "%s", incoming);
    15531554    p = sz_res;
    15541555    while ((*p != ' ' || in_quotes) && *p != '\0') {
     
    15981599        fatal_error("Cannot malloc exclude_paths");
    15991600    }
    1600     (void)asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
     1601    mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    16011602    if (!include_paths && !userdef_filelist) {
    16021603        fatal_error
     
    16061607    sprintf(command, "mkdir -p %s/archives", scratchdir);
    16071608    paranoid_system(command);
    1608     (void)asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
     1609    mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
    16091610    make_hole_for_file(sz_filelist);
    16101611
     
    16461647        log_msg(2, "include_paths = '%s'", include_paths);
    16471648        log_msg(1, "Calculating filelist");
    1648         (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     1649        mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
    16491650        if (strlen(tmp2) < 1) {
    1650             (void)asprintf(&tmp1," ");
     1651            mr_asprintf(&tmp1," ");
    16511652        } else {
    16521653            log_msg(2, "Found windows FS: %s",tmp2);
    1653             (void)asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
     1654            mr_asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    16541655            paranoid_free(tmp2);
    1655             (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
     1656            mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
    16561657            log_msg(2, "Found windows files: %s",tmp2);
    16571658        }
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2209 r2211  
    7474    prev_part_no = 0;
    7575    tmp[0] = '\0';
    76     asprintf(&flaws_str, "%s", "");
     76    mr_asprintf(&flaws_str, "%s", "");
    7777
    7878
     
    363363    assert_string_is_neither_NULL_nor_zerolength(drive);
    364364    assert(mountlist != NULL);
    365     asprintf(&flaws_str, "%s", "");
     365    mr_asprintf(&flaws_str, "%s", "");
    366366
    367367    malloc_string(tmp);
     
    522522    assert(flaws_str_C != NULL);
    523523
    524     asprintf(&flaws_str, "%s", "");
     524    mr_asprintf(&flaws_str, "%s", "");
    525525
    526526    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    532532            (drivelist->el[i].device,
    533533             DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
    534             asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
     534            mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
    535535                    drivelist->el[i].device);
    536536            log_it(tmp);
     
    606606
    607607    for (currline = 0; currline < mountlist->entries; currline++) {
    608         asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
     608        mr_asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
    609609        for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries;
    610610             i++) {
     
    618618        if (copies > 1 && last_copy == currline
    619619            && strcmp(curr_mountpoint, "raid")) {
    620             asprintf(&tmp, " %s %s's.", number_to_text(copies),
     620            mr_asprintf(&tmp, " %s %s's.", number_to_text(copies),
    621621                    curr_mountpoint);
    622622            mr_strcat(flaws_str, "%s", tmp);
     
    657657    for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) {
    658658
    659         asprintf(&drive, "%s", mountlist->el[lino].device);
     659        mr_asprintf(&drive, "%s", mountlist->el[lino].device);
    660660        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    661661            log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
     
    733733                       (void *) &mountlist->el[i],
    734734                       sizeof(struct mountlist_line));
    735                 asprintf(&tmp,
     735                mr_asprintf(&tmp,
    736736                         "%s is available; user may choose to add it to raid device",
    737737                         output_list->el[items - 1].device);
     
    853853            if (j < items) {
    854854                strcat(mountlist->el[items].device, "_dup");
    855                 asprintf(&tmp,
     855                mr_asprintf(&tmp,
    856856                         "Duplicate entry in mountlist - renaming to %s",
    857857                         mountlist->el[items].device);
     
    859859                paranoid_free(tmp);
    860860            }
    861             asprintf(&tmp, "%s", mountlist->el[items].device);
     861            mr_asprintf(&tmp, "%s", mountlist->el[items].device);
    862862            if (strstr(tmp, "/dev/md/")) {
    863863                log_it("format_device() --- Contracting %s", tmp);
     
    10081008    assert(b >= 0);
    10091009
    1010     asprintf(&device, "%s", mountlist->el[a].device);
    1011     asprintf(&mountpoint, "%s", mountlist->el[a].mountpoint);
    1012     asprintf(&format, "%s", mountlist->el[a].format);
     1010    mr_asprintf(&device, "%s", mountlist->el[a].device);
     1011    mr_asprintf(&mountpoint, "%s", mountlist->el[a].mountpoint);
     1012    mr_asprintf(&format, "%s", mountlist->el[a].format);
    10131013
    10141014    size = mountlist->el[a].size;
  • branches/2.2.9/mondo/src/common/libmondo-raid.c

    r2190 r2211  
    11/* libmondo-raid.c                                                subroutines for handling RAID
    22   $Id$
    3 .
    4 
    5 
    6 06/29
    7 - added create_raidtab_from_mdstat()
    8 - changed char[MAX_STR_LEN] to char*
    9 
    10 10/21/2003
    11 - get_next_raidtab_line() --- correctly handle multiple spaces
    12   between label and value
    13 
    14 07/03
    15 - line 447 - changed assert()
    16 
    17 05/08
    18 - cleaned up some FreeBSd-specific stuff
    19 
    20 05/05
    21 - added Joshua Oreman's FreeBSD patches
    22 
    23 04/25
    24 - added a bunch of RAID utilities from mondorestore/mondo-restore.c
    25 
    26 04/24/2003
    27 - added some assert()'s and log_OS_error()'s
    28 
    29 10/19/2002
    30 - added some comments
    31 
    32 07/24
    33 - created
    343*/
    354
     
    4918#include "libmondo-raid.h"
    5019#include "mr_string.h"
     20#include "mr_mem.h"
    5121
    5222#ifdef __FreeBSD__
     
    7747#else
    7848    /*@ buffer ********************************************************** */
    79     char *command;
     49    char *command = NULL;
    8050    int res;
    8151
    82     command = malloc(MAX_STR_LEN * 2);
    83     strcpy(command, "grep \"");
     52    mr_asprintf(&command, "grep \"");
    8453    if (raidno == -1) {
    85         strcat(command, "linear");
     54        mr_strcat(command, "linear");
    8655    } else {
    87         sprintf(command + strlen(command), "raid%d", raidno);
    88     }
    89     strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
     56        mr_strcat(command, "raid%d", raidno);
     57    }
     58    mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
    9059    log_it("Is raid %d registered? Command = '%s'", raidno, command);
    9160    res = system(command);
    9261    paranoid_free(command);
     62
    9363    if (res) {
    9464        return (FALSE);
     
    10431013    pos = string;
    10441014    while (*pos == ' ') pos += 1;
    1045     asprintf(&strtmp, "%s", pos);
     1015    mr_asprintf(&strtmp, "%s", pos);
    10461016    strcpy(string, strtmp);
    10471017    paranoid_free(strtmp);
     
    10641034    token = mr_strtok (string, delims, &lastpos);
    10651035    // get RAID device name
    1066     asprintf(&strtmp,"%s%s", device_prefix, token);
     1036    mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10671037    strcpy(raidlist->el[raidlist->entries].raid_device, strtmp);
    10681038    paranoid_free(strtmp);
     
    11231093      case ' ': // normal data disks
    11241094        raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
    1125         asprintf(&strtmp,"%s%s", device_prefix, token);
     1095        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11261096        strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    11271097        paranoid_free(strtmp);
     
    11301100      case 'S': // spare disks
    11311101        raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
    1132         asprintf(&strtmp,"%s%s", device_prefix, token);
     1102        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11331103        strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    11341104        paranoid_free(strtmp);
     
    11371107      case 'F': // failed disks
    11381108        raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
    1139         asprintf(&strtmp,"%s%s", device_prefix, token);
     1109        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11401110        strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    11411111        paranoid_free(strtmp);
  • branches/2.2.9/mondo/src/common/libmondo-stream.c

    r2176 r2211  
    1313
    1414#include "my-stuff.h"
     15#include "mr_mem.h"
    1516#include "mondostructures.h"
    1617#include "libmondo-devices.h"
     
    369370        }
    370371        if (strstr(fname, "xattr") == NULL) {
    371             asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname);
     372            mr_asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname);
    372373            fatal_error(tmp);
    373374        }
     
    399400        }
    400401        if (strstr(fname, "acl") == NULL) {
    401             asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname);
     402            mr_asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname);
    402403            fatal_error(tmp);
    403404        }
     
    682683
    683684    log_it("Skipping OBDR headers");
    684     asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
     685    mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
    685686    res = run_program_and_log_output(command, 1);
    686687    paranoid_free(command);
    687688
    688     asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device);
     689    mr_asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device);
    689690    res = run_program_and_log_output(command, 1);
    690691    paranoid_free(command);
     
    709710    log_it("Creating OBDR headers");
    710711    /* OBDR: First block 10 kB of zero bs = 512 */
    711     asprintf(&command, "mt -f %s compression off",bkpinfo->media_device);
     712    mr_asprintf(&command, "mt -f %s compression off",bkpinfo->media_device);
    712713    res = run_program_and_log_output(command, 1);
    713714    paranoid_free(command);
    714715
    715     asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
     716    mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
    716717    res += run_program_and_log_output(command, 1);
    717718    paranoid_free(command);
     
    719720    set_tape_block_size_with_mt(512);
    720721
    721     asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);
     722    mr_asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);
    722723    res += run_program_and_log_output(command, 1);
    723724    paranoid_free(command);
     
    726727    set_tape_block_size_with_mt(2048);
    727728
    728     asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);
     729    mr_asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);
    729730    res += run_program_and_log_output(command, 1);
    730731    paranoid_free(command);
  • branches/2.2.9/mondo/src/common/libmondo-string.c

    r2209 r2211  
    88
    99#include "my-stuff.h"
     10#include "mr_mem.h"
    1011#include "mondostructures.h"
    1112#include "libmondo-string.h"
     
    630631    if (strlen(flaws_str) > 0) {
    631632        paranoid_free(flaws_str_A);
    632         asprintf(&flaws_str_A, "%s", flaws_str + 1);
     633        mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
    633634    }
    634635    if (strlen(flaws_str_A) >= 74) {
    635636        for (i = 74; flaws_str_A[i] != ' '; i--);
    636637        paranoid_free(flaws_str_B);
    637         asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
     638        mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
    638639        flaws_str_A[i] = '\0';
    639640    }
     
    641642        for (i = 74; flaws_str_B[i] != ' '; i--);
    642643        paranoid_free(flaws_str_C);
    643         asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
     644        mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
    644645        flaws_str_B[i] = '\0';
    645646    }
  • branches/2.2.9/mondo/src/common/libmondo-tools.c

    r2205 r2211  
    1010
    1111#include "my-stuff.h"
     12#include "mr_mem.h"
    1213#include "mondostructures.h"
    1314#include "lib-common-externs.h"
     
    232233
    233234    uname(&utsn);
    234     asprintf(&tmp, "%s", utsn.machine);
     235    mr_asprintf(&tmp, "%s", utsn.machine);
    235236    return (tmp);
    236237}
     
    420421int post_param_configuration()
    421422{
    422     char *extra_cdrom_params;
    423     char *mondo_mkisofs_sz;
     423    char *extra_cdrom_params = NULL;
     424    char *mondo_mkisofs_sz = NULL;
    424425    char *command;
    425426    char *mtpt;
    426     char *hostname, *ip_address;
     427    char *hostname;
     428    char *ip_address = NULL;
    427429    int retval = 0;
    428430    char *colon;
     
    440442
    441443    assert(bkpinfo != NULL);
    442     malloc_string(extra_cdrom_params);
    443     malloc_string(mondo_mkisofs_sz);
    444444    malloc_string(command);
    445445    malloc_string(mtpt);
    446446    malloc_string(hostname);
    447     malloc_string(ip_address);
    448447    malloc_string(cdr_exe);
    449448    malloc_string(tmp);
     
    497496
    498497    if (bkpinfo->backup_media_type == dvd) {
    499         extra_cdrom_params[0] = '\0';
    500         mondo_mkisofs_sz[0] = '\0';
    501498        if (find_home_of_exe("growisofs")) {
    502499            strcpy(cdr_exe, "growisofs");
     
    506503        }
    507504        if (bkpinfo->nonbootable_backup) {
    508             strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
     505            mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
    509506        } else if
    510507#ifdef __FreeBSD__
     
    515512#ifdef __IA64__
    516513    {
    517         strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);
     514        mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);
    518515    }
    519516#else
    520517    {
    521         strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);
     518        mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);
    522519    }
    523520#endif
    524521        else
    525522        {
    526             strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
     523            mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
    527524        }
    528525        if (bkpinfo->manual_cd_tray) {
     526            paranoid_free(mondo_mkisofs_sz);
    529527            fatal_error("Manual CD tray + DVD not supported yet.");
    530528            // -m isn't supported by growisofs, BTW...
     
    533531                    "%s %s -Z %s . 2>> _ERR_",
    534532                    mondo_mkisofs_sz,
    535                     extra_cdrom_params, bkpinfo->media_device);
     533                    "", bkpinfo->media_device);
     534            paranoid_free(mondo_mkisofs_sz);
    536535        }
    537536        if (getenv ("SUDO_COMMAND")) {
     
    549548    if (bkpinfo->backup_media_type == cdrw
    550549        || bkpinfo->backup_media_type == cdr) {
    551         extra_cdrom_params[0] = '\0';
    552550        if (!bkpinfo->manual_cd_tray) {
    553             strcat(extra_cdrom_params, "-waiti ");
     551            mr_asprintf(&extra_cdrom_params, "-waiti ");
    554552        }
    555553        if (bkpinfo->backup_media_type == cdrw) {
    556             strcat(extra_cdrom_params, "blank=fast ");
     554            mr_asprintf(&extra_cdrom_params, "blank=fast ");
    557555        }
    558556        if (find_home_of_exe("cdrecord")) {
     
    564562        }
    565563        if (bkpinfo->nonbootable_backup) {
    566             strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT);
     564            mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT);
    567565        } else if
    568566#ifdef __FreeBSD__
     
    573571#ifdef __IA64__
    574572    {
    575         strcat(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);
     573        mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);
    576574    }
    577575#else
    578576    {
    579         strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);
     577        mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);
    580578    }
    581579#endif
    582580        else
    583581        {
    584             strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
     582            mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
    585583        }
    586584        if (bkpinfo->manual_cd_tray) {
     
    609607                    bkpinfo->cdrw_speed);
    610608        }
     609        paranoid_free(mondo_mkisofs_sz);
     610        paranoid_free(extra_cdrom_params);
    611611    }                           // end of CD code
    612612
     
    693693                retval++;
    694694            } else {
    695                 strcpy(ip_address, inet_ntoa
     695                mr_asprintf(&ip_address, inet_ntoa
    696696                       ((struct in_addr)
    697697                        *((struct in_addr *) hent->h_addr)));
    698                 strcat(ip_address, strchr(bkpinfo->nfs_mount, ':'));
     698                mr_strcat(ip_address, strchr(bkpinfo->nfs_mount, ':'));
    699699                strcpy(bkpinfo->nfs_mount, ip_address);
     700                paranoid_free(ip_address);
    700701            }
    701702        }
     
    718719    g_backup_media_type = bkpinfo->backup_media_type;
    719720    paranoid_free(mtpt);
    720     paranoid_free(extra_cdrom_params);
    721     paranoid_free(mondo_mkisofs_sz);
    722721    paranoid_free(command);
    723722    paranoid_free(hostname);
    724     paranoid_free(ip_address);
    725723    paranoid_free(cdr_exe);
    726724    paranoid_free(tmp);
     
    758756
    759757    unlink(MONDO_TRACEFILE);
    760     asprintf(&tmp,"rm -Rf %s/changed.files*",MONDO_CACHE);
     758    mr_asprintf(&tmp,"rm -Rf %s/changed.files*",MONDO_CACHE);
    761759    run_program_and_log_output(tmp, FALSE);
    762760    paranoid_free(tmp);
     
    783781    if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    784782        /* purging a potential old tmpdir */
    785         asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
     783        mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
    786784        system(tmp);
    787785        paranoid_free(tmp);
     
    789787
    790788    if (path != NULL) {
    791         asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
     789        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
    792790    } else if (getenv("TMPDIR")) {
    793         asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
     791        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
    794792    } else if (getenv("TMP")) {
    795         asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
     793        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
    796794    } else {
    797         asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
     795        mr_asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
    798796    }
    799797    p = mkdtemp(tmp);
  • branches/2.2.9/mondo/src/common/libmondo-verify.c

    r1747 r2211  
    11/***************************************************************************
    2 libmondo-verify.c  -  description
    3 -----------------
    4 
    5 begin: Fri Apr 19 16:40:35 EDT 2002
    6 copyright : (C) 2002 Mondo  Hugo Rabson
    7 email     : Hugo Rabson <hugorabson@msn.com>
    8 edited by : by Stan Benoit 4/2002
    9 email     : troff@nakedsoul.org
    10 cvsid     : $Id$
     2$Id$
    113***************************************************************************/
    12 
    13 /***************************************************************************
    14  *                                                                         *
    15  *   This program is free software; you can redistribute it and/or modify  *
    16  *   it under the terms of the GNU General Public License as published by  *
    17  *   the Free Software Foundation; either version 2 of the License, or     *
    18  *   (at your option) any later version.                                   *
    19  *                                                                         *
    20  ***************************************************************************/
    21 /* mondo-verify
    22 
    23 
    24 07/07
    25 - added star verify support
    26 
    27 04/04/2004
    28 - added star support
    29 
    30 10/23/2003
    31 - changed "ISO #n" to "<media descriptor> #n"
    32 
    33 10/01
    34 - working on biggiefile verification (CDs)
    35 
    36 09/16
    37 - fixed bug in CD biggie verif'n
    38 
    39 09/15
    40 - state explicitly that we do not verify disk images
    41 
    42 09/13
    43 - working on verify_all_slices_on_CD()
    44 
    45 09/01
    46 - write list of changed biggiefiles (streaming only) to changed.files
    47 
    48 05/05
    49 - exclude /dev/ * from list of changed files
    50 - add Joshua Oreman's FreeBSD patches
    51 
    52 04/24/2003
    53 - added lots of assert()'s and log_OS_error()'s
    54 
    55 09/01 - 09/30/2002
    56 - run_program_and_log_output() now takes boolean operator to specify
    57   whether it will log its activities in the event of _success_
    58 - eject_device() added
    59 - cleaned up 'changed file' feedback a little bit
    60 
    61 08/01 - 08/31
    62 - make sure to prefix bkpinfo->restore_path to local biggiefile fname when
    63   comparing it to the archived copy of biggiefile; otherwise, biggiefile
    64   not found & checksum missing & so on
    65 - exclude "incheckentry xwait()" from changed.files
    66 - cleaned up some log_it() calls
    67 
    68 07/01 - 07/31
    69 - renamed libmondo-verify.c
    70 - say 'bigfile' not 'biggiefile'
    71 - exclude /dev/ * from changed.files
    72 
    73 01/01 - 06/30
    74 - remove /tmp/changed.files.* dead files
    75 - don't pclose() tape after calling closein_tape(): the latter does it already
    76 - fixed bug in verify_cd_image()'s CD-mounting code
    77 - don't write to screen "old cksum.. curr cksum.."
    78 - changed the gawks to awks for the benefit of Debian
    79 - handles files >2GB in size
    80 - fixed bug in /tmp/changed.files-generator
    81 - re-enabled a lot of CD-verification code
    82 - afioballs are saved in %s/tmpfs/ now (%s=tmpdir)
    83 - changed some labels to make them more user-friendly
    84 - don't chdir() anywhere before verifying stuff
    85 - changed files are now detected by verify_tape_backup() and listed in
    86   /tmp/changed.files
    87 - replaced &> with > .. 2>
    88 - still implementing improved tape support
    89 
    90 
    91 Started late Dec, 2001
    92 
    93 -----------------------------------------------------------------------------
    94 */
    954
    965
     
    10110
    10211#include "my-stuff.h"
     12#include "mr_mem.h"
    10313#include "mondostructures.h"
    10414#include "libmondo-verify.h"
     
    419329                            bkpinfo->restore_path,
    420330                            biggiestruct.filename);
    421                 asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed",
     331                mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed",
    422332                            bkpinfo->restore_path,
    423333                            biggiestruct.filename,
     
    1070980    assert(bkpinfo != NULL);
    1071981
    1072     asprintf(&fname, "%s1", bkpinfo->media_device);
     982    mr_asprintf(&fname, "%s1", bkpinfo->media_device);
    1073983    if (is_this_device_mounted(fname)) {
    1074984        log_msg(1, "USB device mounted. Remounting it at the right place");
    1075         asprintf(&tmp, "umount %s", fname);
     985        mr_asprintf(&tmp, "umount %s", fname);
    1076986        run_program_and_log_output(tmp, FALSE);
    1077987        paranoid_free(tmp);
     
    1080990
    1081991    log_msg(1, "Mounting USB device.");
    1082     asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir);
    1083     asprintf(&tmp, "mkdir -p %s", mountpoint);
     992    mr_asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir);
     993    mr_asprintf(&tmp, "mkdir -p %s", mountpoint);
    1084994    run_program_and_log_output(tmp, FALSE);
    1085995    paranoid_free(tmp);
    1086996    /* Mindi always create one single parition on the USB dev */
    1087     asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
     997    mr_asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
    1088998    ret = run_program_and_log_output(tmp, FALSE);
    1089999    paranoid_free(tmp);
     
    10951005    sync();
    10961006    log_msg(2, "OK, I've mounted the USB Disk/Key\n");
    1097     asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     1007    mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    10981008    if (!does_file_exist(tmp)) {
    10991009        log_msg
     
    11121022    verify_all_slices_on_CD(mountpoint);
    11131023
    1114     asprintf(&tmp1, "umount %s", mountpoint);
     1024    mr_asprintf(&tmp1, "umount %s", mountpoint);
    11151025#ifdef __FreeBSD__
    11161026    ret += system(tmp1);
     
    11211031#endif
    11221032    {
    1123         asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1);
     1033        mr_asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1);
    11241034        log_to_screen(tmp);
    11251035        paranoid_free(tmp);
  • branches/2.2.9/mondo/src/common/newt-specific.c

    r2136 r2211  
    1919
    2020#include "my-stuff.h"
     21#include "mr_mem.h"
    2122#include "mondostructures.h"
    2223#include "newt-specific.h"
     
    263264char *tmp1 = NULL;
    264265
    265     asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id);
     266    mr_asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id);
    266267    run_program_and_log_output(tmp, TRUE);
    267268    if (strlen(tmp) > 0) {
    268         asprintf(&tmp1,"kill `%s`", tmp);
     269        mr_asprintf(&tmp1,"kill `%s`", tmp);
    269270        run_program_and_log_output(tmp1, TRUE);
    270271        paranoid_free(tmp1);
     
    386387        run_program_and_log_output("umount " MNT_CDROM, FALSE);
    387388        if (g_selfmounted_isodir) {
    388             asprintf(&command, "umount %s", g_selfmounted_isodir);
     389            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    389390            run_program_and_log_output(command, 1);
    390391            paranoid_free(command);
    391             asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     392            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    392393            run_program_and_log_output(command, 1);
    393394            paranoid_free(command);
     
    405406        printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    406407        if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
    407             asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     408            mr_asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    408409            system(command);
    409410            paranoid_free(command);
     
    956957        /*@ buffers ********************************************************** */
    957958        char *timeline_str;
    958         char *pcline_str;
    959         char *taskprogress;
     959        char *pcline_str = NULL;
     960        char *taskprogress = NULL;
    960961
    961962        /*@ int ************************************************************** */
     
    965966
    966967        malloc_string(timeline_str);
    967         malloc_string(pcline_str);
    968         malloc_string(taskprogress);
    969968        timeline_str[0] = '\0';
    970969//  log_it("update_eval_call_form called");
     
    997996                    time_remaining % 60);
    998997            if (percentage < 3) {
    999                 sprintf(pcline_str, " Working");
     998                mr_asprintf(&pcline_str, " Working");
    1000999                for (j = 0; j < g_mysterious_dot_counter; j++) {
    1001                     strcat(pcline_str, ".");
     1000                    mr_strcat(pcline_str, ".");
    10021001                }
    10031002                for (; j < 27; j++) {
    1004                     strcat(pcline_str, " ");
     1003                    mr_strcat(pcline_str, " ");
    10051004                }
    1006                 sprintf(pcline_str + strlen(pcline_str), " %c",
    1007                         special_dot_char(g_mysterious_dot_counter));
     1005                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    10081006            } else {
    1009                 sprintf(pcline_str, " %3d%% done              %3d%% to go",
     1007                mr_asprintf(&pcline_str, " %3d%% done              %3d%% to go",
    10101008                        percentage, 100 - percentage);
    10111009            }
    10121010            if (g_text_mode) {
    1013                 sprintf(taskprogress, "TASK:  [");
     1011                mr_asprintf(&taskprogress, "TASK:  [");
    10141012                for (i = 0; i < percentage; i += 5) {
    1015                     strcat(taskprogress, "*");
     1013                    mr_strcat(taskprogress, "*");
    10161014                }
    10171015                for (; i < 100; i += 5) {
    1018                     strcat(taskprogress, ".");
     1016                    mr_strcat(taskprogress, ".");
    10191017                }
    10201018                if (percentage >= 3) {
    1021                     sprintf(taskprogress + strlen(taskprogress),
    1022                             "] %3d%% done; %2ld:%02ld to go", percentage,
     1019                    mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
    10231020                            time_remaining / 60, time_remaining % 60);
    10241021                    printf("---evalcall---1--- %s\n",
     
    10271024                    printf("---evalcall---E---\n");
    10281025                }
     1026                paranoid_free(taskprogress);
    10291027            } else {
    10301028                newtScaleSet(g_isoform_scale,
     
    10371035                }
    10381036            }
     1037            paranoid_free(pcline_str);
    10391038        }
    10401039        if (!g_text_mode) {
     
    10431042        }
    10441043        paranoid_free(timeline_str);
    1045         paranoid_free(pcline_str);
    1046         paranoid_free(taskprogress);
    10471044    }
    10481045
     
    10991096        char *percentline_str;
    11001097        char *timeline_str;
    1101         char *taskprogress;
     1098        char *taskprogress = NULL;
    11021099        char *tmp;
    11031100
     
    11051102        percentline_str = malloc(MAX_NEWT_COMMENT_LEN);
    11061103        timeline_str = malloc(MAX_NEWT_COMMENT_LEN);
    1107         taskprogress = malloc(MAX_NEWT_COMMENT_LEN);
    11081104        malloc_string(tmp);
    11091105        if (!g_text_mode) {
     
    11591155            printf("---progress-form---3--- %s\n", blurb3);
    11601156            printf("---progress-form---E---\n");
    1161             sprintf(taskprogress, "TASK:  [");
     1157            mr_asprintf(&taskprogress, "TASK:  [");
    11621158            for (i = 0; i < percentage; i += 5) {
    1163                 strcat(taskprogress, "*");
     1159                mr_strcat(taskprogress, "*");
    11641160            }
    11651161            for (; i < 100; i += 5) {
    1166                 strcat(taskprogress, ".");
     1162                mr_strcat(taskprogress, ".");
    11671163            }
    11681164            if (percentage > 100) {
    11691165                log_msg(2, "percentage = %d", percentage);
    11701166            }
    1171             sprintf(taskprogress + strlen(taskprogress),
    1172                     "] %3d%c", percentage, '%');
    1173             sprintf(taskprogress + strlen(taskprogress),
    1174                     " done; %2ld:%02ld to go",
     1167            mr_strcat(taskprogress, "] %3d%c", percentage, '%');
     1168            mr_strcat(taskprogress, " done; %2ld:%02ld to go",
    11751169                    time_remaining / 60, time_remaining % 60);
    11761170            printf("---progress-form---4--- %s\n", taskprogress);
     1171            paranoid_free(taskprogress);
    11771172        } else {
    11781173            center_string(blurb1, 54);
     
    11991194        paranoid_free(percentline_str);
    12001195        paranoid_free(timeline_str);
    1201         paranoid_free(taskprogress);
    12021196        paranoid_free(tmp);
    12031197    }
     
    14141408        }
    14151409
    1416         asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
     1410        mr_asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
    14171411        if (!(fout = fopen(tmp1, "a"))) {
    14181412            log_msg(2, "Can't write to %s", tmp1);
     
    15031497    char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    15041498        static char comment[100];
    1505         char *tmp;
     1499        char *tmp = NULL;
    15061500
    15071501        iamhere("entering");
    1508         malloc_string(tmp);
    15091502        assert(flentry != NULL);
    15101503        if (flentry->severity == 0) {
    1511             strcpy(tmp, "0   ");
     1504            mr_asprintf(&tmp, "0   ");
    15121505        } else if (flentry->severity == 1) {
    1513             strcpy(tmp, "low ");
     1506            mr_asprintf(&tmp, "low ");
    15141507        } else if (flentry->severity == 2) {
    1515             strcpy(tmp, "med ");
    1516         } else {
    1517             strcpy(tmp, "high");
    1518         }
    1519         strcat(tmp, "  ");
    1520         strncat(tmp, flentry->filename, 100);
    1521         tmp[98] = '\0';
    1522         strcpy(comment, tmp);
     1508            mr_asprintf(&tmp, "med ");
     1509        } else {
     1510            mr_asprintf(&tmp, "high");
     1511        }
     1512        mr_strcat(tmp, "  ");
     1513        mr_strcat(tmp, flentry->filename);
     1514        strncpy(comment, tmp, 99);
    15231515        paranoid_free(tmp);
     1516
    15241517        iamhere("leaving");
    15251518        return (comment);
Note: See TracChangeset for help on using the changeset viewer.