Ignore:
Timestamp:
Aug 18, 2009, 5:28:18 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
File:
1 edited

Legend:

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

    r2332 r2334  
    170170void clean_up_KDE_desktop_if_necessary(void)
    171171{
    172     char *tmp;
    173 
    174     malloc_string(tmp);
    175     strcpy(tmp,
    176            "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \
    177 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \
    178 awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \
    179 else { print $0;};}' $file.old  > $file ; fi ; done");
     172    char *tmp = NULL;
     173
     174    mr_asprintf(tmp, "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } else { print $0;};}' $file.old  > $file ; fi ; done");
    180175    run_program_and_log_output(tmp, 5);
    181     paranoid_free(tmp);
     176    mr_free(tmp);
    182177}
    183178
     
    227222double get_kernel_version(void)
    228223{
    229     char *p, tmp[200];
     224    char *p = NULL;
     225    char *tmp = NULL;
    230226    double d;
    231227#ifdef __FreeBSD__
     
    233229    d = 5.2;                    // :-)
    234230#else
    235     strcpy(tmp, call_program_and_get_last_line_of_output("uname -r"));
     231    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r"));
    236232    p = strchr(tmp, '.');
    237233    if (p) {
     
    244240        }
    245241    }
    246 //  log_msg(1, "tmp = '%s'", tmp);
    247242    d = atof(tmp);
     243    mr_free(tmp);
    248244#endif
    249245    log_msg(1, "g_kernel_version = %f", d);
     
    252248
    253249
    254 
    255 
    256 
    257250/**
    258251 * Get the current time.
     
    263256    return (long) time((void *) 0);
    264257}
    265 
    266 
    267 
    268 
    269 
    270258
    271259
     
    411399    char *command = NULL;
    412400    char *mtpt;
    413     char *hostname;
     401    char *hostname = NULL;
    414402    char *ip_address = NULL;
    415403    int retval = 0;
    416404    char *colon;
    417     char *cdr_exe;
     405    char *cdr_exe = NULL;
    418406    char *tmp = NULL;
    419407    char *p = NULL;
     
    431419
    432420    malloc_string(mtpt);
    433     malloc_string(hostname);
    434     malloc_string(cdr_exe);
    435421    bkpinfo->optimal_set_size =
    436422        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
     
    496482        tmp = find_home_of_exe("growisofs");
    497483        if (tmp) {
    498             strcpy(cdr_exe, "growisofs");
     484            mr_asprintf(cdr_exe, "growisofs");
    499485        }                       // unlikely to be used
    500486        else {
     
    560546        tmp = find_home_of_exe("cdrecord");
    561547        if (tmp) {
    562             strcpy(cdr_exe, "cdrecord");
     548            mr_asprintf(cdr_exe, "cdrecord");
    563549        } else {
    564550            mr_free(tmp);
    565551            tmp = find_home_of_exe("dvdrecord");
    566552            if (tmp) {
    567                 strcpy(cdr_exe, "dvdrecord");
     553                mr_asprintf(cdr_exe, "dvdrecord");
    568554            } else {
    569555                mr_free(tmp);
     
    590576    }
    591577#endif
    592         else
    593         {
     578        else {
    594579            mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
    595580        }
     
    613598            mr_asprintf(bkpinfo->call_make_iso, "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", mondo_mkisofs_sz, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed);
    614599        }
     600        mr_free(cdr_exe);
    615601        paranoid_free(mondo_mkisofs_sz);
    616602        paranoid_free(extra_cdrom_params);
     
    654640            mr_asprintf(iso_path, "%s", iso_tmp + strlen(iso_mnt));
    655641        }
     642        mr_free(iso_mnt);
    656643        mr_free(iso_tmp);
    657644
     
    674661    if (bkpinfo->backup_media_type == nfs) {
    675662        if (bkpinfo->nfs_mount) {
    676             strcpy(hostname, bkpinfo->nfs_mount);
     663            mr_asprintf(hostname, "%s", bkpinfo->nfs_mount);
    677664        } else {
    678665            log_it("nfs_mount is NULL");
    679666            retval++;
    680             strcpy(hostname, "");
     667            mr_asprintf(hostname, "");
    681668        }
    682669        colon = strchr(hostname, ':');
     
    699686            }
    700687        }
     688        mr_free(hostname);
    701689        store_nfs_config();
    702690    }
     
    712700    g_backup_media_type = bkpinfo->backup_media_type;
    713701    paranoid_free(mtpt);
    714     paranoid_free(hostname);
    715     paranoid_free(cdr_exe);
    716702    return (retval);
    717703}
     
    12541240    mr_asprintf(command, "mount | grep -Ew '/boot'");
    12551241    mr_free(tmp);
    1256     mr_asprintf(tmp, call_program_and_get_last_line_of_output(command));
     1242    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    12571243    mr_free(command);
    12581244
Note: See TracChangeset for help on using the changeset viewer.