From c963d75dfdeec11f82e79e727062fbf89afa2c04 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 22 Apr 2012 09:19:23 +1000 Subject: Update EFL to latest beta. --- libraries/eet/src/lib/Eet.h | 17 ++++++-- libraries/eet/src/lib/Makefile.in | 4 ++ libraries/eet/src/lib/eet_alloc.c | 2 +- libraries/eet/src/lib/eet_cipher.c | 71 +++++++++++++++++++++++++++------- libraries/eet/src/lib/eet_data.c | 21 ++-------- libraries/eet/src/lib/eet_dictionary.c | 6 +++ libraries/eet/src/lib/eet_image.c | 19 +++++---- 7 files changed, 99 insertions(+), 41 deletions(-) (limited to 'libraries/eet/src/lib') diff --git a/libraries/eet/src/lib/Eet.h b/libraries/eet/src/lib/Eet.h index 2df7fbf..7495090 100644 --- a/libraries/eet/src/lib/Eet.h +++ b/libraries/eet/src/lib/Eet.h @@ -6,7 +6,7 @@ @mainpage Eet Library Documentation @version 1.5.0 - @date 2000-2011 + @date 2000-2012 Please see the @ref authors page for contact details. @@ -30,7 +30,7 @@ Eet is extremely fast, small and simple. Eet files can be very small and highly compressed, making them very optimal for just sending across the internet without having to archive, compress or decompress and install them. - They allow for lightning-fast random-acess reads once created, making them + They allow for lightning-fast random-access reads once created, making them perfect for storing data that is written once (or rarely) and read many times, but the program does not want to have to read it all in at once. @@ -577,7 +577,7 @@ EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); /** - * Close an eet file handle and flush and writes pending. + * Close an eet file handle and flush pending writes. * @param ef A valid eet file handle. * * This function will flush any pending writes to disk if the eet file @@ -645,6 +645,17 @@ eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); /** + * Return the number of strings inside a dictionary + * @param ed A valid dictionary handle + * @return the number of strings inside a dictionary + * + * @since 1.6.0 + * @ingroup Eet_File_Group + */ +EAPI int +eet_dictionary_count(const Eet_Dictionary *ed); + +/** * Read a specified entry from an eet file and return data * @param ef A valid eet file handle opened for reading. * @param name Name of the entry. eg: "/base/file_i_want". diff --git a/libraries/eet/src/lib/Makefile.in b/libraries/eet/src/lib/Makefile.in index 2a3fec0..c0367b3 100644 --- a/libraries/eet/src/lib/Makefile.in +++ b/libraries/eet/src/lib/Makefile.in @@ -172,6 +172,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -211,6 +213,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ diff --git a/libraries/eet/src/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c index 85351ad..29e276c 100644 --- a/libraries/eet/src/lib/eet_alloc.c +++ b/libraries/eet/src/lib/eet_alloc.c @@ -3,6 +3,7 @@ #endif #include + #include "Eet.h" #include "Eet_private.h" @@ -90,4 +91,3 @@ eet_mempool_shutdown(void) mempool_array[i]->mp = NULL; } } - diff --git a/libraries/eet/src/lib/eet_cipher.c b/libraries/eet/src/lib/eet_cipher.c index 37a0899..2425e22 100644 --- a/libraries/eet/src/lib/eet_cipher.c +++ b/libraries/eet/src/lib/eet_cipher.c @@ -56,6 +56,9 @@ void *alloca(size_t); #ifdef HAVE_CIPHER # ifdef HAVE_GNUTLS +# if defined EET_USE_NEW_PUBKEY_VERIFY_HASH || defined EET_USE_NEW_PRIVKEY_SIGN_DATA +# include +# endif # include # include # else /* ifdef HAVE_GNUTLS */ @@ -497,6 +500,10 @@ eet_identity_sign(FILE *fp, gnutls_datum_t datum = { NULL, 0 }; size_t sign_len = 0; size_t cert_len = 0; +#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA + gnutls_datum_t signum = { NULL, 0 }; + gnutls_privkey_t privkey; +#endif # else /* ifdef HAVE_GNUTLS */ EVP_MD_CTX md_ctx; unsigned int sign_len = 0; @@ -528,6 +535,28 @@ eet_identity_sign(FILE *fp, datum.size = st_buf.st_size; /* Get the signature length */ +#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA + if (gnutls_privkey_init(&privkey) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + if (gnutls_privkey_import_x509(privkey, key->private_key, 0) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + if (gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA1, 0, &datum, &signum) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + sign = signum.data; + sign_len = signum.size; +#else if (gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0, &datum, sign, &sign_len) && !sign_len) @@ -550,6 +579,7 @@ eet_identity_sign(FILE *fp, goto on_error; } +#endif /* Get the certificate length */ if (gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert, @@ -696,6 +726,10 @@ eet_identity_check(const void *data_base, gnutls_datum_t datum; gnutls_datum_t signature; # if EET_USE_NEW_GNUTLS_API +# if EET_USE_NEW_PUBKEY_VERIFY_HASH + gnutls_pubkey_t pubkey; + gnutls_digest_algorithm_t hash_algo; +# endif unsigned char *hash; gcry_md_hd_t md; int err; @@ -724,28 +758,32 @@ eet_identity_check(const void *data_base, hash = gcry_md_read(md, GCRY_MD_SHA1); if (!hash) - { - gcry_md_close(md); - return NULL; - } + goto on_error; datum.size = gcry_md_get_algo_dlen(GCRY_MD_SHA1); datum.data = hash; +# ifdef EET_USE_NEW_PUBKEY_VERIFY_HASH + if (gnutls_pubkey_init(&pubkey) < 0) + goto on_error; + + if (gnutls_pubkey_import_x509(pubkey, cert, 0) < 0) + goto on_error; + + if (gnutls_pubkey_get_verify_algorithm(pubkey, &signature, &hash_algo) < 0) + goto on_error; + + if (gnutls_pubkey_verify_hash(pubkey, 0, &datum, &signature) < 0) + goto on_error; +# else if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature)) - { - gcry_md_close(md); - return NULL; - } + goto on_error; +# endif if (sha1) { *sha1 = malloc(datum.size); - if (!*sha1) - { - gcry_md_close(md); - return NULL; - } + if (!*sha1) goto on_error; memcpy(*sha1, hash, datum.size); *sha1_length = datum.size; @@ -818,6 +856,13 @@ eet_identity_check(const void *data_base, *raw_signature_length = sign_len; return cert_der; +# ifdef HAVE_GNUTLS +# if EET_USE_NEW_GNUTLS_API + on_error: + gcry_md_close(md); + return NULL; +# endif +# endif #else /* ifdef HAVE_SIGNATURE */ data_base = NULL; data_length = 0; diff --git a/libraries/eet/src/lib/eet_data.c b/libraries/eet/src/lib/eet_data.c index 56b9ee0..d502f44 100644 --- a/libraries/eet/src/lib/eet_data.c +++ b/libraries/eet/src/lib/eet_data.c @@ -21,18 +21,6 @@ #include "Eet.h" #include "Eet_private.h" -#ifdef _WIN32 -# define FMT_CHAR "%c" -# define FMT_UCHAR "%c" -# define FMT_LONG_LONG "%I64i" -# define FMT_ULONG_LONG "%I64u" -#else -# define FMT_CHAR "%hhi" -# define FMT_UCHAR "%hhu" -# define FMT_LONG_LONG "%lli" -# define FMT_ULONG_LONG "%llu" -#endif - /* * routines for doing data -> struct and struct -> data conversion * @@ -3108,7 +3096,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, if (!strcmp(tok3, "char:")) { n->type = EET_T_CHAR; - sscanf(tok4, FMT_CHAR, + sscanf(tok4, "%hhi", &(n->data.value.c)); } else if (!strcmp(tok3, "short:")) @@ -3126,7 +3114,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "long_long:")) { n->type = EET_T_LONG_LONG; - sscanf(tok4, FMT_LONG_LONG, + sscanf(tok4, "%lli", &(n->data.value.l)); } else if (!strcmp(tok3, "float:")) @@ -3144,7 +3132,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "uchar:")) { n->type = EET_T_UCHAR; - sscanf(tok4, FMT_UCHAR, + sscanf(tok4, "%hhu", &(n->data.value.uc)); } else if (!strcmp(tok3, "ushort:")) @@ -3162,7 +3150,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "ulong_long:")) { n->type = EET_T_ULONG_LONG; - sscanf(tok4, FMT_ULONG_LONG, + sscanf(tok4, "%llu", &(n->data.value.ul)); } else if (!strcmp(tok3, "string:")) @@ -4996,4 +4984,3 @@ eet_data_xattr_cipher_set(const char *filename, return ret; } - diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c index 287860d..c79239b 100644 --- a/libraries/eet/src/lib/eet_dictionary.c +++ b/libraries/eet/src/lib/eet_dictionary.c @@ -169,6 +169,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed, return 0; } +EAPI int +eet_dictionary_count(const Eet_Dictionary *ed) +{ + return ed->count; +} + int eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int idx) diff --git a/libraries/eet/src/lib/eet_image.c b/libraries/eet/src/lib/eet_image.c index 8c6c03c..b622236 100644 --- a/libraries/eet/src/lib/eet_image.c +++ b/libraries/eet/src/lib/eet_image.c @@ -246,7 +246,7 @@ eet_data_image_jpeg_rgb_decode(const void *data, unsigned int w, unsigned int h, unsigned int row_stride); -static void * +static int eet_data_image_jpeg_alpha_decode(const void *data, int size, unsigned int src_x, @@ -560,7 +560,7 @@ eet_data_image_jpeg_rgb_decode(const void *data, return 1; } -static void * +static int eet_data_image_jpeg_alpha_decode(const void *data, int size, unsigned int src_x, @@ -577,6 +577,10 @@ eet_data_image_jpeg_alpha_decode(const void *data, unsigned int x, y, l, scans; unsigned int i, iw; + /* FIXME: handle src_x, src_y and row_stride correctly */ + if (!d) + return 0; + memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct)); cinfo.err = jpeg_std_error(&(jerr.pub)); @@ -584,14 +588,14 @@ eet_data_image_jpeg_alpha_decode(const void *data, jerr.pub.emit_message = _JPEGErrorHandler2; jerr.pub.output_message = _JPEGErrorHandler; if (setjmp(jerr.setjmp_buffer)) - return NULL; + return 0; jpeg_create_decompress(&cinfo); if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size)) { jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } jpeg_read_header(&cinfo, TRUE); @@ -609,7 +613,7 @@ eet_data_image_jpeg_alpha_decode(const void *data, cinfo.src = NULL; jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } /* end head decoding */ @@ -620,11 +624,12 @@ eet_data_image_jpeg_alpha_decode(const void *data, cinfo.src = NULL; jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } tdata = alloca(w * 16 * 3); ptr2 = d; + if (cinfo.output_components == 1) { for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++) @@ -666,7 +671,7 @@ eet_data_image_jpeg_alpha_decode(const void *data, /* end data decoding */ jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); - return d; + return 1; } static void * -- cgit v1.1