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
File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.