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/mondorestore/mondo-rstr-compare.c

    r1930 r2211  
    11/***************************************************************************
    2        mondo-compare.c  -  compares mondoarchive data
    3                              -------------------
    4     begin                : Fri Apr 25 2003
    5     copyright            : (C) 2000 by Hugo Rabson
    6     email                : Hugo Rabson <hugorabson@msn.com>
    72    cvsid                : $Id$
    83***************************************************************************/
    94
    10 /***************************************************************************
    11  *                                                                         *
    12  *   This program is free software; you can redistribute it and/or modify  *
    13  *   it under the terms of the GNU General Public License as published by  *
    14  *   the Free Software Foundation; either version 2 of the License, or     *
    15  *   (at your option) any later version.                                   *
    16  *                                                                         *
    17  ***************************************************************************/
    18 
    19 /***************************************************************************
    20  *                         Change Log                                      *
    21  ***************************************************************************
    22 .
    23 
    24 
    25 
    26 10/21/2003
    27 - changed "/mnt/cdrom" to MNT_CDROM
    28 
    29 10/18
    30 - don't say unknown compressor if no compressor at all
    31 
    32 09/17
    33 - cleaned up logging & conversion-to-changed.txt
    34 - cleaned up compare_mode()
    35 
    36 09/16
    37 - fixed bad malloc(),free() pairs in compare_a_biggiefile()
    38 
    39 09/14
    40 - compare_mode() --- a couple of strings were the wrong way round,
    41   e.g. changed.txt and changed.files
    42 
    43 05/05
    44 - exclude /dev/ * from list of changed files
    45 
    46 04/30
    47 - added textonly mode
    48 
    49 04/27
    50 - improved compare_mode() to allow for ISO/cd/crazy people
    51 
    52 04/25
    53 - first incarnation
    54 */
    55 
    56 
    575#include <pthread.h>
    586#include "my-stuff.h"
     7#include "mr_mem.h"
    598#include "../common/mondostructures.h"
    609#include "../common/libmondo.h"
     
    9746    char *original_cksum_ptr;
    9847    char *bigfile_fname_ptr;
    99     char *tmp_ptr;
     48    char *tmp_ptr = NULL;
    10049    char *command_ptr;
    10150
     
    11766    malloc_string(bigfile_fname_ptr);
    11867    malloc_string(command_ptr);
    119     malloc_string(tmp_ptr);
    12068
    12169  /*********************************************************************
     
    12674    memset(original_cksum_ptr, '\0', sizeof(original_cksum));
    12775    memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));
    128     memset(tmp_ptr, '\0', sizeof(tmp));
    12976    memset(command_ptr, '\0', sizeof(command));
    13077  /** end **/
     
    13481            insist_on_this_cd_number((++g_current_media_number));
    13582        } else {
    136             sprintf(tmp_ptr,
     83            mr_asprintf(&tmp_ptr,
    13784                    "No CD's left. No biggiefiles left. No prob, Bob.");
    13885            log_msg(2, tmp_ptr);
     86            paranoid_free(tmp_ptr);
    13987            return (0);
    14088        }
    14189    }
    14290    if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
    143         sprintf(tmp_ptr,
     91        mr_asprintf(&tmp_ptr,
    14492                "Cannot open bigfile %ld (%s)'s info file",
    14593                bigfileno + 1, bigfile_fname_ptr);
    14694        log_to_screen(tmp_ptr);
     95        paranoid_free(tmp_ptr);
    14796        return (1);
    14897    }
     
    156105    log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum);
    157106
    158     sprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);
    159 
    160107    if (!g_text_mode) {
     108        mr_asprintf(&tmp_ptr, "Comparing %s", bigfile_fname_ptr);
    161109        newtDrawRootText(0, 22, tmp_ptr);
     110        paranoid_free(tmp_ptr);
    162111        newtRefresh();
    163112    }
     
    173122    }
    174123    log_msg(2, command_ptr);
    175     sprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
     124    mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
    176125    paranoid_system(tmp_ptr);
     126    paranoid_free(tmp_ptr);
     127
    177128    if (system(command_ptr)) {
    178129        log_OS_error("Warning - command failed");
     
    197148        }
    198149    }
    199     sprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1,
     150    mr_asprintf(&tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1,
    200151            bigfile_fname_ptr);
    201152    if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) {
    202         strcat(tmp_ptr, " ... OK");
    203     } else {
    204         strcat(tmp_ptr, "... changed");
     153        mr_strcat(tmp_ptr, " ... OK");
     154    } else {
     155        mr_strcat(tmp_ptr, "... changed");
    205156        retval++;
    206157    }
    207158    log_msg(1, tmp_ptr);
     159    paranoid_free(tmp_ptr);
     160
    208161    if (retval) {
    209162        if (!(fout = fopen(MONDO_CACHE"/changed.txt", "a"))) {
     
    222175    paranoid_free(command_ptr);
    223176    paranoid_free(command);
    224     paranoid_free(tmp_ptr);
    225177    paranoid_free(tmp);
    226178
     
    302254
    303255  /***  needs malloc *********/
    304     char *command, *tmp, *filelist_name, *logfile, *archiver_exe,
     256    char *command, *tmp, *filelist_name, *logfile,
    305257        *compressor_exe;
     258    char *archiver_exe = NULL;
    306259
    307260    malloc_string(command);
     
    309262    malloc_string(filelist_name);
    310263    malloc_string(logfile);
    311     malloc_string(archiver_exe);
    312264    malloc_string(compressor_exe);
    313265
     
    331283
    332284    if (use_star) {
    333         strcpy(archiver_exe, "star");
    334     } else {
    335         strcpy(archiver_exe, "afio");
     285        mr_asprintf(&archiver_exe, "star");
     286    } else {
     287        mr_asprintf(&archiver_exe, "afio");
    336288    }
    337289
     
    344296        {
    345297            if (!strcmp(compressor_exe, "bzip2")) {
    346                 strcat(archiver_exe, " -bz");
     298                mr_strcat(archiver_exe, " -bz");
    347299            } else {
    348300                fatal_error
     
    373325                BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
    374326    }
     327    paranoid_free(archiver_exe);
     328
    375329#undef BUFSIZE
    376330
     
    405359    paranoid_free(filelist_name);
    406360    paranoid_free(logfile);
    407     paranoid_free(archiver_exe);
    408361    paranoid_free(compressor_exe);
    409362    return (retval);
Note: See TracChangeset for help on using the changeset viewer.