Commit 6b64142b authored by Arturo Tena/libole2's avatar Arturo Tena/libole2

All bbd blocks are marked as unused (incluiding additional ones).

parent 45642675
.deps .deps
Makefile.in Makefile.in
Makefile Makefile
.libs
*.lo
*.la
1999-09-26 Arturo Tena <arturo@directmail.org>
* ms-ole.c (characterise_block): Added recognized block type.
(read_bb): mark all bbd blocks as unused (incluiding additional ones).
1999-09-26 Arturo Tena <arturo@directmail.org> 1999-09-26 Arturo Tena <arturo@directmail.org>
* ms-ole.c (ms_ole_open): Fixed bug: core dumped when called with an * ms-ole.c (ms_ole_open): Fixed bug: core dumped when called with an
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define OLE_DEBUG 0 #define OLE_DEBUG 0
/* FIXME tenix laola defines 0xfffffffc too */ /* FIXME tenix laola defines 0xfffffffc too (add it to characterise_block too */
#define SPECIAL_BLOCK 0xfffffffd #define SPECIAL_BLOCK 0xfffffffd
#define END_OF_CHAIN 0xfffffffe #define END_OF_CHAIN 0xfffffffe
#define UNUSED_BLOCK 0xffffffff #define UNUSED_BLOCK 0xffffffff
...@@ -326,11 +326,11 @@ characterise_block (MsOle *f, BLP blk, char **ans) ...@@ -326,11 +326,11 @@ characterise_block (MsOle *f, BLP blk, char **ans)
*ans = "special"; *ans = "special";
return; return;
} }
/* FIXME tenix added block type
else if (nblk == END_OF_CHAIN) { else if (nblk == END_OF_CHAIN) {
*ans = "end of chain"; *ans = "end of chain";
return;
} }
*/
*ans = "unknown"; *ans = "unknown";
g_return_if_fail (f); g_return_if_fail (f);
g_return_if_fail (f->bb); g_return_if_fail (f->bb);
...@@ -420,17 +420,19 @@ get_next_block (MsOle *f, BLP blk) ...@@ -420,17 +420,19 @@ get_next_block (MsOle *f, BLP blk)
/* blk is an index of the complete fat, and /* blk is an index of the complete fat, and
an index of the complete fat is the number of a BBD block */ an index of the complete fat is the number of a BBD block */
BLP bbd = GET_BBD_LIST (f, blk/(BB_BLOCK_SIZE/4)); BLP bbd = GET_BBD_LIST (f, blk/(BB_BLOCK_SIZE/4));
return MS_OLE_GET_GUINT32 (BB_R_PTR(f,bbd) + 4*(blk%(BB_BLOCK_SIZE/4))); return MS_OLE_GET_GUINT32 (BB_R_PTR(f,bbd)
+ 4*(blk%(BB_BLOCK_SIZE/4)));
} }
static int static int
read_bb (MsOle *f) read_bb (MsOle *f)
{ {
guint32 numbbd; /* FIXME tenix may be later we wish to split this function */
BLP lp; guint32 numbbd;
guint32 num_add_bbd_lists; BLP lp;
BLP missing_lps; guint32 num_add_bbd_lists;
guint32 visited_add_bbd_list; BLP missing_lps;
guint32 visited_add_bbd_list;
g_return_val_if_fail (f, 0); g_return_val_if_fail (f, 0);
g_return_val_if_fail (f->mem, 0); g_return_val_if_fail (f->mem, 0);
...@@ -440,8 +442,9 @@ read_bb (MsOle *f) ...@@ -440,8 +442,9 @@ read_bb (MsOle *f)
/* Sanity checks */ /* Sanity checks */
/* FIXME tenix reading big files /* FIXME tenix reading big files
if (numbbd < ((f->length - BB_BLOCK_SIZE + ((BB_BLOCK_SIZE*BB_BLOCK_SIZE)/4) - 1) / if (numbbd < ((f->length - BB_BLOCK_SIZE
((BB_BLOCK_SIZE*BB_BLOCK_SIZE)/4))) { + ((BB_BLOCK_SIZE*BB_BLOCK_SIZE)/4) - 1)
/ ((BB_BLOCK_SIZE*BB_BLOCK_SIZE)/4))) {
printf ("Duff block descriptors\n"); printf ("Duff block descriptors\n");
return 0; return 0;
} }
...@@ -449,7 +452,8 @@ read_bb (MsOle *f) ...@@ -449,7 +452,8 @@ read_bb (MsOle *f)
/* FIXME tenix check if size is small, there's no add bbd lists */ /* FIXME tenix check if size is small, there's no add bbd lists */
/* Add BBD's that live in the BBD list */ /* Add BBD's that live in the BBD list */
for (lp=0;(lp<(f->length/BB_BLOCK_SIZE)-1)&&(lp<MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4);lp++) { for (lp = 0; (lp<(f->length/BB_BLOCK_SIZE)-1)
&&(lp<MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4); lp++) {
BLP tmp = get_next_block (f, lp); BLP tmp = get_next_block (f, lp);
g_array_append_val (f->bb, tmp); g_array_append_val (f->bb, tmp);
} }
...@@ -459,23 +463,27 @@ read_bb (MsOle *f) ...@@ -459,23 +463,27 @@ read_bb (MsOle *f)
if (num_add_bbd_lists > 0) { if (num_add_bbd_lists > 0) {
/* FIXME change g_assert and return a error to user */ /* FIXME change g_assert and return a error to user */
g_assert (lp == MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4); g_assert (lp == MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4);
missing_lps = (f->length/BB_BLOCK_SIZE) - 1 - MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4; missing_lps = (f->length/BB_BLOCK_SIZE) - 1
- MAX_SIZE_BBD_LIST*BB_BLOCK_SIZE/4;
visited_add_bbd_list = GET_FIRST_ADD_BBD_LIST (f); visited_add_bbd_list = GET_FIRST_ADD_BBD_LIST (f);
for (lp=0; lp<missing_lps; lp++) { for (lp = 0; lp < missing_lps; lp++) {
BLP tmp; BLP tmp;
BLP bbd; BLP bbd;
/* bbd here means the number of one block that belongs to the fat */ /* bbd here means the number of one block that
bbd = MS_OLE_GET_GUINT32 (BB_R_PTR(f,visited_add_bbd_list) belongs to the fat */
+ 4*(lp/(BB_BLOCK_SIZE/4))); bbd = MS_OLE_GET_GUINT32 (BB_R_PTR (f,
tmp = MS_OLE_GET_GUINT32 (BB_R_PTR(f,bbd) + 4*(lp%(BB_BLOCK_SIZE/4))); visited_add_bbd_list) + 4*(lp/(BB_BLOCK_SIZE/4)));
tmp = MS_OLE_GET_GUINT32 (BB_R_PTR(f,bbd)
+ 4*(lp%(BB_BLOCK_SIZE/4)));
g_array_append_val (f->bb, tmp); g_array_append_val (f->bb, tmp);
if ((lp!=0) && !(lp%(MAX_SIZE_ADD_BBD_LIST*(BB_BLOCK_SIZE/4)))) { if ((lp!=0) && !(lp%(MAX_SIZE_ADD_BBD_LIST*
(BB_BLOCK_SIZE/4)))) {
/* This lp lives in the next add bbd list */ /* This lp lives in the next add bbd list */
visited_add_bbd_list = MS_OLE_GET_GUINT32( visited_add_bbd_list = MS_OLE_GET_GUINT32(
BB_R_PTR(f,visited_add_bbd_list) BB_R_PTR(f,visited_add_bbd_list)
+4*MAX_SIZE_ADD_BBD_LIST); +4*MAX_SIZE_ADD_BBD_LIST);
if (visited_add_bbd_list == END_OF_CHAIN) { if (visited_add_bbd_list == END_OF_CHAIN) {
if (lp + 1 != missing_lps) { if (lp + 1 != missing_lps) {
/* FIXME tenix error */ /* FIXME tenix error */
...@@ -483,21 +491,47 @@ read_bb (MsOle *f) ...@@ -483,21 +491,47 @@ read_bb (MsOle *f)
} }
} }
} }
/* FIXME tenix do we check if we have visited all lp's but there are more /* FIXME tenix do we check if we have visited all lp's but
additional lists? */ there are more additional lists? */
} }
/* Free up those blocks for a bit. */ /* Mark as unused bbd blocks */
/* FIXME tenix reading big files for (lp=0; lp < MIN (numbbd, MAX_SIZE_BBD_LIST); lp++)
for (lp=0;lp<numbbd;lp++)
g_array_index (f->bb, BLP, GET_BBD_LIST(f,lp)) = UNUSED_BLOCK; g_array_index (f->bb, BLP, GET_BBD_LIST(f,lp)) = UNUSED_BLOCK;
*/ if (num_add_bbd_lists > 0) {
visited_add_bbd_list = GET_FIRST_ADD_BBD_LIST (f);
g_array_index (f->bb, BLP, visited_add_bbd_list) = UNUSED_BLOCK;
for (lp = 0; lp < numbbd - MAX_SIZE_BBD_LIST; lp++) {
BLP tmp;
BLP bbd;
bbd = MS_OLE_GET_GUINT32 (BB_R_PTR(f,
visited_add_bbd_list) + 4*lp);
g_array_index (f->bb, BLP, bbd) = UNUSED_BLOCK;
if ((lp!=0) && !(lp%(MAX_SIZE_ADD_BBD_LIST
*(BB_BLOCK_SIZE/4)))) {
/* This lp lives in the next add bbd list */
visited_add_bbd_list = MS_OLE_GET_GUINT32(
BB_R_PTR(f,visited_add_bbd_list)
+4*MAX_SIZE_ADD_BBD_LIST);
if (visited_add_bbd_list == END_OF_CHAIN) {
if (lp + 1 != missing_lps) {
/* FIXME tenix error */
}
}
g_array_index (f->bb, BLP, visited_add_bbd_list)
= UNUSED_BLOCK;
}
}
}
g_assert (f->bb->len < f->length/BB_BLOCK_SIZE); g_assert (f->bb->len < f->length/BB_BLOCK_SIZE);
/* FIXME tenix better check?: g_assert (f->bb->len == f->length/BB_BLOCK_SIZE - 1); */ /* FIXME tenix better check?:
g_assert (f->bb->len == f->length/BB_BLOCK_SIZE - 1); */
/* More sanity checks */ /* More sanity checks */
/* for (lp=0;lp<numbbd;lp++) { /* for (lp=0; lp<numbbd; lp++) {
BLP bbdblk = GET_BBD_LIST(f, lp); BLP bbdblk = GET_BBD_LIST(f, lp);
if (g_array_index(f->bb, BLP, bbdblk) != SPECIAL_BLOCK) { if (g_array_index(f->bb, BLP, bbdblk) != SPECIAL_BLOCK) {
printf ("Error - BBD blocks not marked correctly\n"); printf ("Error - BBD blocks not marked correctly\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment