Eet_Data_Element *ede;
Eet_Data_Element *tmp;
+ /* Sanity check to avoid crash later at runtime */
+ if (type < EET_T_UNKNOW ||
+ type >= EET_T_LAST)
+ {
+ CRIT("Preventing later bug due to unknow type: %i", type);
+ return ;
+ }
+ if (offset < 0)
+ {
+ CRIT("Preventing later buffer underrun : offset = %i", offset);
+ return ;
+ }
+ if (offset > edd->size)
+ {
+ CRIT("Preventing later buffer overrun : offset = %i in a structure of %i bytes", offset, edd->size);
+ return ;
+ }
+ if (group_type == EET_G_UNKNOWN && type != EET_T_UNKNOW)
+ {
+ if (offset + eet_basic_codec[type - 1].size > edd->size)
+ {
+ CRIT("Preventing later buffer overrun : offset = %i, size = %i in a structure of %i bytes", offset, eet_basic_codec[type - 1].size, edd->size);
+ return ;
+ }
+ }
+ else if ((offset + sizeof (void*)) > (unsigned int) edd->size)
+ {
+ CRIT("Preventing later buffer overrun : offset = %i, estimated size = %i in a structure of %i bytes", offset, sizeof (void*), edd->size);
+ return ;
+ }
+
/* UNION, VARIANT type would not work with simple type, we need a way to map the type. */
if ((group_type == EET_G_UNION
|| group_type == EET_G_VARIANT)
const char *name,
const char *cipher_key,
const void *data,
- int compress)
+ int comp)
{
Eet_Dictionary *ed;
void *data_enc;
if (!data_enc)
return 0;
- val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
+ val = eet_write_cipher(ef, name, data_enc, size, comp, cipher_key);
free(data_enc);
return val;
}
Eet_Data_Descriptor *edd,
const char *name,
const void *data,
- int compress)
+ int comp)
{
- return eet_data_write_cipher(ef, edd, name, NULL, data, compress);
+ return eet_data_write_cipher(ef, edd, name, NULL, data, comp);
}
static void
if (ede)
{
if (IS_POINTER_TYPE(type))
- subsize = eet_basic_codec[ede->type].size;
+ subsize = eet_basic_codec[ede->type - 1].size;
else
subsize = ede->subtype->size;
eet_data_encode(ed, ds, data, ede->name, size, ede->type, ede->group_type);
if (IS_POINTER_TYPE(ede->type))
- subsize = eet_basic_codec[ede->type].size;
+ subsize = eet_basic_codec[ede->type - 1].size;
else
subsize = ede->subtype->size;
const char *cipher_key,
const char *text,
int textlen,
- int compress)
+ int comp)
{
Eet_Dictionary *ed;
void *data_enc;
if (!data_enc)
return 0;
- val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
+ val = eet_write_cipher(ef, name, data_enc, size, comp, cipher_key);
free(data_enc);
return val;
}
const char *name,
const char *text,
int textlen,
- int compress)
+ int comp)
{
- return eet_data_undump_cipher(ef, name, NULL, text, textlen, compress);
+ return eet_data_undump_cipher(ef, name, NULL, text, textlen, comp);
}
EAPI void *
const char *name,
const char *cipher_key,
Eet_Node *node,
- int compress)
+ int comp)
{
Eet_Dictionary *ed;
void *data_enc;
if (!data_enc)
return 0;
- val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
+ val = eet_write_cipher(ef, name, data_enc, size, comp, cipher_key);
free(data_enc);
return val;
}