summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-02-04 22:33:06 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-02-04 22:33:06 +0000
commit304bedae982c284afce2fe1b7ea4f86708be184b (patch)
tree201959369d6eb1f5f620f4218f6ec696c76c3121
parenta1b093733a765c854715cdccc5bb21854e601a7d (diff)
downloaddrakx-backup-do-not-use-304bedae982c284afce2fe1b7ea4f86708be184b.tar
drakx-backup-do-not-use-304bedae982c284afce2fe1b7ea4f86708be184b.tar.gz
drakx-backup-do-not-use-304bedae982c284afce2fe1b7ea4f86708be184b.tar.bz2
drakx-backup-do-not-use-304bedae982c284afce2fe1b7ea4f86708be184b.tar.xz
drakx-backup-do-not-use-304bedae982c284afce2fe1b7ea4f86708be184b.zip
fix bug when creating marfiles with file-not-found in args
-rw-r--r--mdk-stage1/mar/mar-frontend.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/mdk-stage1/mar/mar-frontend.c b/mdk-stage1/mar/mar-frontend.c
index 82f870d57..2e87626db 100644
--- a/mdk-stage1/mar/mar-frontend.c
+++ b/mdk-stage1/mar/mar-frontend.c
@@ -56,31 +56,23 @@ mar_create_file(char *dest_file, char **files)
int current_delta_rawdata = 0;
int filetable_size;
char * temp_marfile_buffer;
- int total_length;
+ int total_length = 0;
- /* calculate offset of ``raw_files_data'' */
- total_length = sizeof(char); /* ``char 0'' */
- while (files[filenum])
- {
- total_length += 2*sizeof(int) /* file_length, data_offset */ + strlen(files[filenum]) + 1;
- filenum++;
- }
- DEBUG_MAR(printf("D: mar::create_marfile number-of-files %d offset-data-start %d\n", filenum, current_offset_rawdata););
-
- filetable_size = total_length;
-
- /* calculate length of final uncompressed marfile, for malloc */
- filenum = 0;
+ filetable_size = sizeof(char); /* ``char 0'' */
while (files[filenum])
{
int fsiz = file_size(files[filenum]);
if (fsiz == -1)
files[filenum] = fnf_tag;
- else
+ else {
+ filetable_size += 2*sizeof(int) /* file_length, data_offset */ + strlen(files[filenum]) + 1;
total_length += fsiz;
+ }
filenum++;
}
+ total_length += filetable_size;
+
temp_marfile_buffer = (char *) malloc(total_length); /* create the whole file in-memory (not with alloca! it can be bigger than typical limit for stack of programs (ulimit -s) */
DEBUG_MAR(printf("D: mar::create_marfile total-length %d\n", total_length););