Skip to content

Commit

Permalink
dynamic memory allocation for path table was corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
gozora committed Oct 22, 2015
1 parent f73747f commit 3c39bfc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions ebiso.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* ebiso.c
*
* Version: 0.1.2
* Version: 0.1.3
*
* Release date: 20.10.2015
* Release date: 21.10.2015
*
* Copyright 2015 Vladimir (sodoma) Gozora <[email protected]>
*
Expand Down Expand Up @@ -224,7 +224,7 @@ int main(int argc, char *argv[]) {
printf("%-5s %-4s %-55s %-11s %-3s %-9s %-5s %-7s %-12s %-5s %-11s %-6s %-8s %-7s\n", \
"Level", "PID", "Name", "Size", "ID", "LBA", "Flag", "Blocks", "conf_name", \
"Len", "ISO9660_len", "CE_LBA", "Full_len", "CE_off");
for (i = 0; i <= 8; i++)
for (i = 0; i <= 128; i++)
disp_level(list, i);
break;
}
Expand Down
6 changes: 3 additions & 3 deletions include/ebiso.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* ebiso.h
*
* Version: 0.1.2
* Version: 0.1.3
*
* Release date: 20.10.2015
* Release date: 21.10.2015
*
* Copyright 2015 Vladimir (sodoma) Gozora <[email protected]>
*
Expand Down Expand Up @@ -33,7 +33,7 @@
#include <getopt.h>

#define PROGNAME "ebiso"
#define VERSION "0.1.2"
#define VERSION "0.1.3"

#ifdef DEBUG
static void disp_level(struct file_list_t *list_to_display, int level);
Expand Down
9 changes: 5 additions & 4 deletions lib/iso9660.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* iso9660.c
*
* Version: 0.2.0
* Version: 0.2.1
*
* Release date: 20.10.2015
*
Expand Down Expand Up @@ -71,7 +71,7 @@ uint32_t iso9660_header(void **header, struct file_list_t file_list, struct ISO_
int offset = ISO_data.path_table_size / (BLOCK_SIZE + 1);
uint32_t header_size = 0;
time_t time_now = time(NULL);

char system_identifier[32] = VOLUME_ID; // "LINUX"
char volume_identifier[32] = SYSTEM_ID; // "CDROM"
uint64_t volume_space_size = get_int32_LSB_MSB(ISO_data.LBA_last); // Size of whole ISO image in blocks ( * BLOCK_SIZE = ISO size [B])
Expand Down Expand Up @@ -194,13 +194,14 @@ int iso9660_path_table(struct file_list_t *file_list, void **path_table, enum en
/* Dynamic memory allocation BEGIN */
entry_len = PT_RECORD_LEN + rr_file_list->name_conv_len + pad_len;
mem_free -= entry_len;

if (mem_free < 0) {
count++;

if ((tmp_realloc = realloc(path_table_start, count * BLOCK_SIZE)) != NULL) {
path_table_start = tmp_realloc;
mem_free = BLOCK_SIZE + (BLOCK_SIZE - path_table_size);
memset(path_table_start + BLOCK_SIZE, 0, BLOCK_SIZE);
mem_free = BLOCK_SIZE + mem_free;
memset(path_table_start + (count * BLOCK_SIZE) - BLOCK_SIZE, 0, BLOCK_SIZE);
rr_path_table = path_table_start + path_table_size;
}
else {
Expand Down

0 comments on commit 3c39bfc

Please sign in to comment.