FIX: allow open of eet files with 0 key entries. this kind of breaks

some usage scenarios.



SVN revision: 63800
This commit is contained in:
Carsten Haitzler 2011-10-04 10:03:09 +00:00
parent 8edb994133
commit 4376c4f995
2 changed files with 15 additions and 5 deletions

View File

@ -530,3 +530,8 @@
2011-09-15 Cedric Bail
* Add eet_data_xattr_cipher_get and eet_data_xattr_cipher_set.
2011-10-04 Carsten Haitzler (The Rasterman)
* Fix issue where an empty eet file (no keys) is not openable
for read/write anymore. Allow it.

View File

@ -882,8 +882,8 @@ eet_internal_read2(Eet_File *ef)
bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE *
num_dictionary_entries;
/* we can't have <= 0 values here - invalid */
if (eet_test_close((num_directory_entries <= 0), ef))
/* we can't have > 0x7fffffff values here - invalid */
if (eet_test_close((num_directory_entries > 0x7fffffff), ef))
return NULL;
/* we can't have more bytes directory and bytes in dictionaries than the size of the file */
@ -912,6 +912,10 @@ eet_internal_read2(Eet_File *ef)
return NULL;
signature_base_offset = 0;
if (num_directory_entries == 0)
{
signature_base_offset = ef->data_size;
}
/* actually read the directory block - all of it, into ram */
for (i = 0; i < num_directory_entries; ++i)
@ -1134,7 +1138,8 @@ eet_internal_read1(Eet_File *ef)
EXTRACT_INT(byte_entries, ef->data, idx);
/* we can't have <= 0 values here - invalid */
if (eet_test_close((num_entries <= 0) || (byte_entries <= 0), ef))
if (eet_test_close((num_entries > 0x7fffffff) ||
(byte_entries > 0x7fffffff), ef))
return NULL;
/* we can't have more entires than minimum bytes for those! invalid! */
@ -1142,8 +1147,8 @@ eet_internal_read1(Eet_File *ef)
return NULL;
/* check we will not outrun the file limit */
if (eet_test_close(((byte_entries + (int)sizeof(int) * 3) > ef->data_size),
ef))
if (eet_test_close(((byte_entries + (int)(sizeof(int) * 3)) >
ef->data_size), ef))
return NULL;
/* allocate header */