Ignore:
Timestamp:
Aug 18, 2009, 2:37:58 PM (11 years ago)
Author:
Bruno Cornec
Message:

r3333@localhost: bruno | 2009-08-08 01:58:31 +0200

  • bkpinfo->prefix is now dynamically assigned
  • Fix newt mondoarchive
File:
1 edited

Legend:

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

    r2321 r2322  
    203203    int i;
    204204    char *tmp;
     205    char *tmp1 = NULL;
    205206    char ch;
    206207
     
    224225    tmp[i] = '\0';
    225226    outval = atol(tmp);
     227    paranoid_free(tmp);
    226228    if (ch == 'g' || ch == 'G') {
    227229        outval = outval * 1024;
     
    239241        fatal_error("Integer overflow.");
    240242    } else if (ch != 'm' && ch != 'M') {
    241         sprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')",
    242                 incoming, ch);
    243         fatal_error(tmp);
    244     }
    245     paranoid_free(tmp);
     243        mr_asprintf(&tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     244        fatal_error(tmp1);
     245    }
    246246    return (outval);
    247247}
     
    549549    /*@ buffers **************************************************** */
    550550    static char output[MAX_STR_LEN];
    551     static char suffix[MAX_STR_LEN];
     551    char *suffix = NULL;
    552552
    553553    /*@ end vars *************************************************** */
     
    555555    assert_string_is_neither_NULL_nor_zerolength(path);
    556556    if (s[0] != '\0') {
    557         sprintf(suffix, ".%s", s);
     557        mr_asprintf(&suffix, ".%s", s);
    558558    } else {
    559         suffix[0] = '\0';
    560     }
    561     sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno,
    562             suffix);
     559        mr_asprintf(&suffix, "");
     560    }
     561    sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno, suffix);
     562    mr_free(suffix);
    563563    return (output);
    564564}
     
    925925{
    926926    int sev;
    927     char *reason;
    928     char *filename;
    929 
    930     malloc_string(reason);
    931     malloc_string(filename);
    932    
     927    char *reason = NULL;
     928    char *filename = NULL;
     929
    933930    // out_reason might be null on purpose, so don't bomb if it is :) OK?
    934931    assert_string_is_neither_NULL_nor_zerolength(fn);
    935932    if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) {
    936         strcpy(filename, fn + strlen(MNT_RESTORING));
     933        mr_asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));
    937934    } else if (fn[0] != '/') {
    938         sprintf(filename, "/%s", fn);
     935        mr_asprintf(&filename, "/%s", fn);
    939936    } else {
    940         strcpy(filename, fn);
     937        mr_asprintf(&filename, "%s", fn);
    941938    }
    942939
    943940    sev = 3;
    944     sprintf(reason,
    945             "Changed since backup. Consider running a differential backup in a day or two.");
     941    mr_asprintf(&reason, "Changed since backup. Consider running a differential backup in a day or two.");
     942
    946943    if (!strncmp(filename, "/var/", 5)) {
    947944        sev = 2;
    948         sprintf(reason,
    949                 "/var's contents will change regularly, inevitably.");
     945        mr_free(reason);
     946        mr_asprintf(&reason, "/var's contents will change regularly, inevitably.");
    950947    }
    951948    if (!strncmp(filename, "/home", 5)) {
    952949        sev = 2;
    953         sprintf(reason,
    954                 "It's in your /home directory. Therefore, it is important.");
     950        mr_free(reason);
     951        mr_asprintf(&reason, "It's in your /home directory. Therefore, it is important.");
    955952    }
    956953    if (!strncmp(filename, "/usr/", 5)) {
    957954        sev = 3;
    958         sprintf(reason,
    959                 "You may have installed/removed software during the backup.");
     955        mr_free(reason);
     956        mr_asprintf(&reason, "You may have installed/removed software during the backup.");
    960957    }
    961958    if (!strncmp(filename, "/etc/", 5)) {
    962959        sev = 3;
    963         sprintf(reason,
    964                 "Do not edit config files while backing up your PC.");
     960        mr_free(reason);
     961        mr_asprintf(&reason, "Do not edit config files while backing up your PC.");
    965962    }
    966963    if (!strcmp(filename, "/etc/adjtime")
    967964        || !strcmp(filename, "/etc/mtab")) {
    968965        sev = 1;
    969         sprintf(reason, "This file changes all the time. It's OK.");
     966        mr_free(reason);
     967        mr_asprintf(&reason, "This file changes all the time. It's OK.");
    970968    }
    971969    if (!strncmp(filename, "/root/", 6)) {
    972970        sev = 3;
    973         sprintf(reason, "Were you compiling/editing something in /root?");
     971        mr_free(reason);
     972        mr_asprintf(&reason, "Were you compiling/editing something in /root?");
    974973    }
    975974    if (!strncmp(filename, "/root/.", 7)) {
    976975        sev = 2;
    977         sprintf(reason, "Temp or 'dot' files changed in /root.");
     976        mr_free(reason);
     977        mr_asprintf(&reason, "Temp or 'dot' files changed in /root.");
    978978    }
    979979    if (!strncmp(filename, "/var/lib/", 9)) {
    980980        sev = 2;
    981         sprintf(reason, "Did you add/remove software during backing?");
     981        mr_free(reason);
     982        mr_asprintf(&reason, "Did you add/remove software during backing?");
    982983    }
    983984    if (!strncmp(filename, "/var/lib/rpm", 12)) {
    984985        sev = 3;
    985         sprintf(reason, "Did you add/remove software during backing?");
     986        mr_free(reason);
     987        mr_asprintf(&reason, "Did you add/remove software during backing?");
    986988    }
    987989    if (!strncmp(filename, "/var/lib/slocate", 16)) {
    988990        sev = 1;
    989         sprintf(reason,
    990                 "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
     991        mr_free(reason);
     992        mr_asprintf(&reason, "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
    991993    }
    992994    if (!strncmp(filename, "/var/log/", 9)
     
    994996        || !strcmp(filename + strlen(filename) - 4, ".log")) {
    995997        sev = 1;
    996         sprintf(reason,
    997                 "Log files change frequently as the computer runs. Fret not.");
     998        mr_free(reason);
     999        mr_asprintf(&reason, "Log files change frequently as the computer runs. Fret not.");
    9981000    }
    9991001    if (!strncmp(filename, "/var/spool", 10)) {
    10001002        sev = 1;
    1001         sprintf(reason,
    1002                 "Background processes or printers were active. This does not affect the integrity of your backup.");
     1003        mr_free(reason);
     1004        mr_asprintf(&reason, "Background processes or printers were active. This does not affect the integrity of your backup.");
    10031005    }
    10041006    if (!strncmp(filename, "/var/spool/mail", 10)) {
    10051007        sev = 2;
    1006         sprintf(reason, "Mail was sent/received during backup.");
     1008        mr_free(reason);
     1009        mr_asprintf(&reason, "Mail was sent/received during backup.");
    10071010    }
    10081011    if (filename[strlen(filename) - 1] == '~') {
    10091012        sev = 1;
    1010         sprintf(reason,
    1011                 "Backup copy of another file which was modified recently.");
     1013        mr_free(reason);
     1014        mr_asprintf(&reason, "Backup copy of another file which was modified recently.");
    10121015    }
    10131016    if (strstr(filename, "cache")) {
    10141017        sev = 1;
    1015         sprintf(reason,
    1016                 "Part of a cache of data. Caches change from time to time. Don't worry.");
     1018        mr_free(reason);
     1019        mr_asprintf(&reason, "Part of a cache of data. Caches change from time to time. Don't worry.");
    10171020    }
    10181021    if (!strncmp(filename, "/var/run/", 9)
     
    10211024        || strstr(filename, "/.Xauthority")) {
    10221025        sev = 1;
    1023         sprintf(reason,
    1024                 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
     1026        mr_free(reason);
     1027        mr_asprintf(&reason, "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
    10251028    }
    10261029    if (out_reason) {
    10271030        strcpy(out_reason, reason);
    10281031    }
    1029     paranoid_free(filename);
    1030     paranoid_free(reason);
     1032    mr_free(filename);
     1033    mr_free(reason);
    10311034    return (sev);
    10321035}
     
    10781081    /*@ buffers ******************************************* */
    10791082    char *outstr = NULL;
    1080     char *pos_w_commas, *tmp;
     1083    char *pos_w_commas = NULL;
    10811084    char *mds = NULL;
     1085    char *tmp = NULL;
    10821086
    10831087    assert(bkpinfo != NULL);
    10841088
    10851089    if (bkpinfo->media_size[g_current_media_number] <= 0) {
    1086         malloc_string(pos_w_commas);
    1087         malloc_string(tmp);
    1088         sprintf(tmp, "%lld", g_tape_posK);
    1089         strcpy(pos_w_commas, commarize(tmp));
    1090         paranoid_free(tmp);
     1090        mr_asprintf(&tmp, "%lld", g_tape_posK);
     1091        mr_asprintf(&pos_w_commas, "%s", commarize(tmp));
     1092        mr_free(tmp);
    10911093        mr_asprintf(&outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
    1092         paranoid_free(pos_w_commas);
     1094        mr_free(pos_w_commas);
    10931095        return (outstr);
    10941096    }
Note: See TracChangeset for help on using the changeset viewer.