New upstream version 1.9.1
Ricardo Mones
5 years ago
37 | 37 | #endif |
38 | 38 | |
39 | 39 | #ifndef LIBETPAN_VERSION_MINOR |
40 | #define LIBETPAN_VERSION_MINOR 8 | |
40 | #define LIBETPAN_VERSION_MINOR 9 | |
41 | 41 | #endif |
42 | 42 | |
43 | 43 | #ifndef LIBETPAN_REENTRANT |
46 | 46 | #endif |
47 | 47 | |
48 | 48 | #ifndef LIBETPAN_API_CURRENT |
49 | #define LIBETPAN_API_CURRENT 21 | |
49 | #define LIBETPAN_API_CURRENT 22 | |
50 | 50 | #endif |
51 | 51 | |
52 | 52 | #ifndef LIBETPAN_API_REVISION |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for libetpan 1.8.0. | |
2 | # Generated by GNU Autoconf 2.69 for libetpan 1.9.1. | |
3 | 3 | # |
4 | 4 | # Report bugs to <libetpan-devel@lists.sourceforge.net>. |
5 | 5 | # |
589 | 589 | # Identity of this package. |
590 | 590 | PACKAGE_NAME='libetpan' |
591 | 591 | PACKAGE_TARNAME='libetpan' |
592 | PACKAGE_VERSION='1.8.0' | |
593 | PACKAGE_STRING='libetpan 1.8.0' | |
592 | PACKAGE_VERSION='1.9.1' | |
593 | PACKAGE_STRING='libetpan 1.9.1' | |
594 | 594 | PACKAGE_BUGREPORT='libetpan-devel@lists.sourceforge.net' |
595 | 595 | PACKAGE_URL='' |
596 | 596 | |
1381 | 1381 | # Omit some internal or obsolete options to make the list less imposing. |
1382 | 1382 | # This message is too long to be a string in the A/UX 3.1 sh. |
1383 | 1383 | cat <<_ACEOF |
1384 | \`configure' configures libetpan 1.8.0 to adapt to many kinds of systems. | |
1384 | \`configure' configures libetpan 1.9.1 to adapt to many kinds of systems. | |
1385 | 1385 | |
1386 | 1386 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1387 | 1387 | |
1452 | 1452 | |
1453 | 1453 | if test -n "$ac_init_help"; then |
1454 | 1454 | case $ac_init_help in |
1455 | short | recursive ) echo "Configuration of libetpan 1.8.0:";; | |
1455 | short | recursive ) echo "Configuration of libetpan 1.9.1:";; | |
1456 | 1456 | esac |
1457 | 1457 | cat <<\_ACEOF |
1458 | 1458 | |
1588 | 1588 | test -n "$ac_init_help" && exit $ac_status |
1589 | 1589 | if $ac_init_version; then |
1590 | 1590 | cat <<\_ACEOF |
1591 | libetpan configure 1.8.0 | |
1591 | libetpan configure 1.9.1 | |
1592 | 1592 | generated by GNU Autoconf 2.69 |
1593 | 1593 | |
1594 | 1594 | Copyright (C) 2012 Free Software Foundation, Inc. |
2078 | 2078 | This file contains any messages produced by compilers while |
2079 | 2079 | running configure, to aid debugging if configure makes a mistake. |
2080 | 2080 | |
2081 | It was created by libetpan $as_me 1.8.0, which was | |
2081 | It was created by libetpan $as_me 1.9.1, which was | |
2082 | 2082 | generated by GNU Autoconf 2.69. Invocation command line was |
2083 | 2083 | |
2084 | 2084 | $ $0 $@ |
2948 | 2948 | |
2949 | 2949 | # Define the identity of the package. |
2950 | 2950 | PACKAGE='libetpan' |
2951 | VERSION='1.8.0' | |
2951 | VERSION='1.9.1' | |
2952 | 2952 | |
2953 | 2953 | |
2954 | 2954 | cat >>confdefs.h <<_ACEOF |
3137 | 3137 | |
3138 | 3138 | |
3139 | 3139 | VERSION_MAJOR=1 |
3140 | VERSION_MINOR=8 | |
3141 | VERSION_MICRO=0 | |
3140 | VERSION_MINOR=9 | |
3141 | VERSION_MICRO=1 | |
3142 | 3142 | |
3143 | 3143 | libcurl_major_required=0 |
3144 | 3144 | libcurl_minor_required=0 |
3145 | 3145 | |
3146 | API_CURRENT=21 | |
3146 | API_CURRENT=22 | |
3147 | 3147 | API_REVISION=0 |
3148 | 3148 | API_COMPATIBILITY=20 |
3149 | 3149 | |
17140 | 17140 | SSLLIBS="-lcrypto $SSLLIBS" |
17141 | 17141 | fi |
17142 | 17142 | |
17143 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 | |
17144 | $as_echo_n "checking for SSL_library_init in -lssl... " >&6; } | |
17145 | if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : | |
17143 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_CTX_new in -lssl" >&5 | |
17144 | $as_echo_n "checking for SSL_CTX_new in -lssl... " >&6; } | |
17145 | if ${ac_cv_lib_ssl_SSL_CTX_new+:} false; then : | |
17146 | 17146 | $as_echo_n "(cached) " >&6 |
17147 | 17147 | else |
17148 | 17148 | ac_check_lib_save_LIBS=$LIBS |
17156 | 17156 | #ifdef __cplusplus |
17157 | 17157 | extern "C" |
17158 | 17158 | #endif |
17159 | char SSL_library_init (); | |
17159 | char SSL_CTX_new (); | |
17160 | 17160 | int |
17161 | 17161 | main () |
17162 | 17162 | { |
17163 | return SSL_library_init (); | |
17163 | return SSL_CTX_new (); | |
17164 | 17164 | ; |
17165 | 17165 | return 0; |
17166 | 17166 | } |
17167 | 17167 | _ACEOF |
17168 | 17168 | if ac_fn_c_try_link "$LINENO"; then : |
17169 | ac_cv_lib_ssl_SSL_library_init=yes | |
17170 | else | |
17171 | ac_cv_lib_ssl_SSL_library_init=no | |
17169 | ac_cv_lib_ssl_SSL_CTX_new=yes | |
17170 | else | |
17171 | ac_cv_lib_ssl_SSL_CTX_new=no | |
17172 | 17172 | fi |
17173 | 17173 | rm -f core conftest.err conftest.$ac_objext \ |
17174 | 17174 | conftest$ac_exeext conftest.$ac_ext |
17175 | 17175 | LIBS=$ac_check_lib_save_LIBS |
17176 | 17176 | fi |
17177 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5 | |
17178 | $as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } | |
17179 | if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : | |
17177 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_CTX_new" >&5 | |
17178 | $as_echo "$ac_cv_lib_ssl_SSL_CTX_new" >&6; } | |
17179 | if test "x$ac_cv_lib_ssl_SSL_CTX_new" = xyes; then : | |
17180 | 17180 | with_openssl=yes |
17181 | 17181 | fi |
17182 | 17182 | |
19047 | 19047 | # report actual input values of CONFIG_FILES etc. instead of their |
19048 | 19048 | # values after options handling. |
19049 | 19049 | ac_log=" |
19050 | This file was extended by libetpan $as_me 1.8.0, which was | |
19050 | This file was extended by libetpan $as_me 1.9.1, which was | |
19051 | 19051 | generated by GNU Autoconf 2.69. Invocation command line was |
19052 | 19052 | |
19053 | 19053 | CONFIG_FILES = $CONFIG_FILES |
19113 | 19113 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
19114 | 19114 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
19115 | 19115 | ac_cs_version="\\ |
19116 | libetpan config.status 1.8.0 | |
19116 | libetpan config.status 1.9.1 | |
19117 | 19117 | configured by $0, generated by GNU Autoconf 2.69, |
19118 | 19118 | with options \\"\$ac_cs_config\\" |
19119 | 19119 |
1 | 1 | # Process this file with autoconf to produce a configure script. |
2 | 2 | |
3 | 3 | m4_define([maj_version], [1]) |
4 | m4_define([min_version], [8]) | |
5 | m4_define([mic_version], [0]) | |
6 | m4_define([api_current], [21]) | |
4 | m4_define([min_version], [9]) | |
5 | m4_define([mic_version], [1]) | |
6 | m4_define([api_current], [22]) | |
7 | 7 | m4_define([api_revision], [0]) |
8 | 8 | m4_define([api_compatibility], [20]) |
9 | 9 | dnl API version |
211 | 211 | AC_CHECK_HEADER(openssl/ssl.h, [ |
212 | 212 | AC_CHECK_LIB(rsaref, main, [SSLLIBS="-lrsaref"]) |
213 | 213 | AC_CHECK_LIB(crypto, main, [SSLLIBS="-lcrypto $SSLLIBS"], [], [$SSLLIBS]) |
214 | AC_CHECK_LIB(ssl, SSL_library_init, with_openssl=yes, [], [$SSLLIBS])]) | |
214 | AC_CHECK_LIB(ssl, SSL_CTX_new, with_openssl=yes, [], [$SSLLIBS])]) | |
215 | 215 | if test "x$with_openssl" != "xyes"; then |
216 | 216 | CPPFLAGS="$OCPPFLAGS" |
217 | 217 | LDFLAGS="$OLDFLAGS" |
189 | 189 | struct sockaddr_un sa; |
190 | 190 | int s; |
191 | 191 | |
192 | if (!(memcpy(sa.sun_path, path, strlen(path)))) { | |
192 | if (sizeof(sa.sun_path) <= strlen(path)) { | |
193 | return -1; | |
194 | } | |
195 | ||
196 | if (!(memcpy(sa.sun_path, path, strlen(path)+1))) { | |
193 | 197 | return -1; |
194 | 198 | } |
195 | 199 | sa.sun_family = AF_UNIX; |
428 | 428 | int fd; |
429 | 429 | int idle_fd; |
430 | 430 | int cancel_fd; |
431 | struct timeval delay; | |
432 | 431 | int r; |
433 | 432 | #if defined(WIN32) |
434 | 433 | fd_set readfds; |
532 | 531 | if (cancel_fd > maxfd) { |
533 | 532 | maxfd = cancel_fd; |
534 | 533 | } |
534 | struct timeval delay; | |
535 | 535 | delay.tv_sec = max_idle_delay; |
536 | 536 | delay.tv_usec = 0; |
537 | 537 |
261 | 261 | void mailstream_openssl_init_not_required(void) |
262 | 262 | { |
263 | 263 | #ifdef USE_SSL |
264 | mailstream_ssl_init_lock(); | |
264 | 265 | MUTEX_LOCK(&ssl_lock); |
265 | 266 | openssl_init_done = 1; |
266 | 267 | MUTEX_UNLOCK(&ssl_lock); |
407 | 408 | |
408 | 409 | static int mailstream_openssl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) |
409 | 410 | { |
410 | struct mailstream_ssl_context * ssl_context = (struct mailstream_ssl_context *)SSL_CTX_get_app_data(ssl->ctx); | |
411 | struct mailstream_ssl_context * ssl_context = (struct mailstream_ssl_context *)SSL_CTX_get_app_data(SSL_get_SSL_CTX(ssl)); | |
411 | 412 | |
412 | 413 | if (x509 == NULL || pkey == NULL) { |
413 | 414 | return 0; |
426 | 427 | } |
427 | 428 | |
428 | 429 | static struct mailstream_ssl_data * ssl_data_new_full(int fd, time_t timeout, |
429 | SSL_METHOD * method, void (* callback)(struct mailstream_ssl_context * ssl_context, void * cb_data), | |
430 | const SSL_METHOD * method, void (* callback)(struct mailstream_ssl_context * ssl_context, void * cb_data), | |
430 | 431 | void * cb_data) |
431 | 432 | { |
432 | 433 | struct mailstream_ssl_data * ssl_data; |
566 | 567 | #if GNUTLS_VERSION_NUMBER <= 0x020c00 |
567 | 568 | st->type = type; |
568 | 569 | #else |
569 | st->key_type = type; | |
570 | st->cert_type = type; | |
571 | st->key_type = GNUTLS_PRIVKEY_X509; | |
570 | 572 | #endif |
571 | 573 | st->cert.x509 = &(ssl_context->client_x509); |
572 | 574 | st->key.x509 = ssl_context->client_pkey; |
1453 | 1455 | } |
1454 | 1456 | |
1455 | 1457 | result = carray_new(4); |
1456 | for(skpos = 0 ; skpos < sk_num(skx) ; skpos ++) { | |
1457 | X509 * x = (X509 *) sk_value(skx, skpos); | |
1458 | for(skpos = 0 ; skpos < sk_num((_STACK *) skx) ; skpos ++) { | |
1459 | X509 * x = (X509 *) sk_value((_STACK *) skx, skpos); | |
1458 | 1460 | unsigned char * p; |
1459 | 1461 | MMAPString * str; |
1460 | 1462 | int length = i2d_X509(x, NULL); |
1490 | 1490 | |
1491 | 1491 | multipart = mailprivacy_new_file_part(privacy, NULL, |
1492 | 1492 | "multipart/signed", -1); |
1493 | if (multipart == NULL) { | |
1494 | res = MAIL_ERROR_MEMORY; | |
1495 | goto unlink_description; | |
1496 | } | |
1493 | 1497 | |
1494 | 1498 | content = multipart->mm_content_type; |
1495 | 1499 | |
1870 | 1874 | |
1871 | 1875 | multipart = mailprivacy_new_file_part(privacy, NULL, |
1872 | 1876 | "multipart/encrypted", -1); |
1877 | if (multipart == NULL) { | |
1878 | res = MAIL_ERROR_MEMORY; | |
1879 | goto unlink_description; | |
1880 | } | |
1873 | 1881 | |
1874 | 1882 | content = multipart->mm_content_type; |
1875 | 1883 | |
1914 | 1922 | version_filename, |
1915 | 1923 | "application/pgp-encrypted", |
1916 | 1924 | MAILMIME_MECHANISM_8BIT); |
1917 | if (r != MAIL_NO_ERROR) { | |
1918 | mailprivacy_mime_clear(multipart); | |
1919 | mailmime_free(multipart); | |
1920 | res = r; | |
1925 | if (version_mime == NULL) { | |
1926 | mailprivacy_mime_clear(multipart); | |
1927 | mailmime_free(multipart); | |
1928 | res = MAIL_ERROR_MEMORY; | |
1921 | 1929 | goto unlink_version; |
1922 | 1930 | } |
1923 | 1931 | |
1937 | 1945 | encrypted_filename, |
1938 | 1946 | "application/octet-stream", |
1939 | 1947 | MAILMIME_MECHANISM_8BIT); |
1940 | if (r != MAIL_NO_ERROR) { | |
1941 | mailprivacy_mime_clear(multipart); | |
1942 | mailmime_free(multipart); | |
1943 | res = r; | |
1948 | if (encrypted_mime == NULL) { | |
1949 | mailprivacy_mime_clear(multipart); | |
1950 | mailmime_free(multipart); | |
1951 | res = MAIL_ERROR_MEMORY; | |
1944 | 1952 | goto unlink_version; |
1945 | 1953 | } |
1946 | 1954 | |
2091 | 2099 | |
2092 | 2100 | multipart = mailprivacy_new_file_part(privacy, NULL, |
2093 | 2101 | "multipart/encrypted", -1); |
2102 | if (multipart == NULL) { | |
2103 | res = MAIL_ERROR_MEMORY; | |
2104 | goto unlink_description; | |
2105 | } | |
2094 | 2106 | |
2095 | 2107 | content = multipart->mm_content_type; |
2096 | 2108 | |
2134 | 2146 | version_filename, |
2135 | 2147 | "application/pgp-encrypted", |
2136 | 2148 | MAILMIME_MECHANISM_8BIT); |
2137 | if (r != MAIL_NO_ERROR) { | |
2138 | mailprivacy_mime_clear(multipart); | |
2139 | mailmime_free(multipart); | |
2140 | res = r; | |
2149 | if (version_mime == NULL) { | |
2150 | mailprivacy_mime_clear(multipart); | |
2151 | mailmime_free(multipart); | |
2152 | res = MAIL_ERROR_MEMORY; | |
2141 | 2153 | goto unlink_version; |
2142 | 2154 | } |
2143 | 2155 | |
2157 | 2169 | encrypted_filename, |
2158 | 2170 | "application/octet-stream", |
2159 | 2171 | MAILMIME_MECHANISM_8BIT); |
2160 | if (r != MAIL_NO_ERROR) { | |
2161 | mailprivacy_mime_clear(multipart); | |
2162 | mailmime_free(multipart); | |
2163 | res = r; | |
2172 | if (encrypted_mime == NULL) { | |
2173 | mailprivacy_mime_clear(multipart); | |
2174 | mailmime_free(multipart); | |
2175 | res = MAIL_ERROR_MEMORY; | |
2164 | 2176 | goto unlink_version; |
2165 | 2177 | } |
2166 | 2178 |
36 | 36 | # include <config.h> |
37 | 37 | #endif |
38 | 38 | |
39 | #if __APPLE__ | |
40 | #include <TargetConditionals.h> | |
41 | #endif | |
39 | 42 | #include "mailprivacy_smime.h" |
40 | 43 | #include <string.h> |
41 | 44 | #ifdef WIN32 |
1536 | 1539 | char quoted_store_cert_filename[PATH_MAX]; |
1537 | 1540 | int r; |
1538 | 1541 | char command[PATH_MAX]; |
1539 | ||
1542 | ||
1543 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |
1544 | //https://github.com/dinhviethoa/libetpan/issues/275 | |
1545 | //get_cert_from_sig is not needed on iOS | |
1546 | return MAIL_ERROR_COMMAND; | |
1547 | #endif | |
1548 | ||
1540 | 1549 | if (* cert_dir == '\0') |
1541 | 1550 | return MAIL_ERROR_INVAL; |
1542 | 1551 | |
1596 | 1605 | "openssl pkcs7 -inform DER -in '%s' -out '%s' -print_certs 2>/dev/null", |
1597 | 1606 | quoted_signature_filename, quoted_store_cert_filename); |
1598 | 1607 | |
1608 | #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR | |
1609 | //https://github.com/dinhviethoa/libetpan/issues/275 | |
1610 | //system() is not supported on iOS 11. | |
1599 | 1611 | r = system(command); |
1612 | #endif | |
1613 | ||
1600 | 1614 | if (WEXITSTATUS(r) != 0) { |
1601 | 1615 | res = MAIL_ERROR_COMMAND; |
1602 | 1616 | goto unlink_signature; |
36 | 36 | # include <config.h> |
37 | 37 | #endif |
38 | 38 | |
39 | #if __APPLE__ | |
40 | #include <TargetConditionals.h> | |
41 | #endif | |
42 | ||
39 | 43 | #include "mailprivacy_tools.h" |
40 | 44 | #include "mailprivacy_tools_private.h" |
41 | 45 | |
1322 | 1326 | char * stdoutfile, char * stderrfile, |
1323 | 1327 | int * bad_passphrase) |
1324 | 1328 | { |
1329 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR | |
1330 | //https://github.com/dinhviethoa/libetpan/issues/275 | |
1331 | //mailprivacy_spawn_and_wait is not needed on iOS | |
1332 | return MAIL_ERROR_COMMAND; | |
1333 | #endif | |
1334 | ||
1325 | 1335 | #ifdef WIN32 |
1326 | 1336 | int res; |
1327 | 1337 | SECURITY_ATTRIBUTES sec_attr; |
1508 | 1518 | dup2(fd_err, 2); |
1509 | 1519 | close(fd_err); |
1510 | 1520 | |
1521 | #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR | |
1522 | //https://github.com/dinhviethoa/libetpan/issues/275 | |
1523 | //system() is not supported on iOS 11. | |
1511 | 1524 | status = system(command); |
1512 | ||
1525 | #endif | |
1526 | ||
1513 | 1527 | exit(WEXITSTATUS(status)); |
1514 | 1528 | } |
1515 | 1529 | break; |
344 | 344 | ext_data->ext_extension->ext_id == MAILIMAP_EXTENSION_ACL && |
345 | 345 | ext_data->ext_type == MAILIMAP_ACL_TYPE_MYRIGHTS_DATA) { |
346 | 346 | * result = (struct mailimap_acl_myrights_data *)ext_data->ext_data; |
347 | ext_data->ext_data = NULL; | |
347 | 348 | /* remove the element from rsp_extension_list */ |
348 | 349 | clist_delete(session->imap_response_info->rsp_extension_list, cur); |
350 | mailimap_extension_data_free(ext_data); | |
349 | 351 | |
350 | 352 | break; |
351 | 353 | } |
165 | 165 | if (data == NULL) |
166 | 166 | return; |
167 | 167 | |
168 | if (data->ext_extension != NULL) | |
168 | if (data->ext_extension != NULL && data->ext_data != NULL) | |
169 | /* ext_free() includes free(data) */ | |
169 | 170 | data->ext_extension->ext_free(data); |
170 | 171 | else |
171 | 172 | free(data); |
32 | 32 | #define MAILIMAP_EXTENSION_TYPES_H |
33 | 33 | |
34 | 34 | #include <libetpan/mailstream.h> |
35 | #include <libetpan/mailimap_types.h> | |
35 | 36 | |
36 | 37 | struct mailimap_extension_data; |
37 | 38 |
1200 | 1200 | LIBETPAN_EXPORT |
1201 | 1201 | void mailimap_flag_list_free(struct mailimap_flag_list * flag_list) |
1202 | 1202 | { |
1203 | clist_foreach(flag_list->fl_list, (clist_func) mailimap_flag_free, NULL); | |
1204 | clist_free(flag_list->fl_list); | |
1203 | if (flag_list->fl_list) { | |
1204 | clist_foreach(flag_list->fl_list, (clist_func) mailimap_flag_free, NULL); | |
1205 | clist_free(flag_list->fl_list); | |
1206 | } | |
1205 | 1207 | free(flag_list); |
1206 | 1208 | } |
1207 | 1209 |
1172 | 1172 | return res; |
1173 | 1173 | } |
1174 | 1174 | |
1175 | LIBETPAN_EXPORT | |
1176 | 1175 | static int mailimf_fws_atom_for_word_parse(const char * message, size_t length, |
1177 | 1176 | size_t * indx, char ** result, int * p_missing_closing_quote) |
1178 | 1177 | { |
1161 | 1161 | size_t cur_offset; |
1162 | 1162 | char * dest; |
1163 | 1163 | size_t size; |
1164 | int i; | |
1164 | unsigned int i; | |
1165 | 1165 | |
1166 | 1166 | size = 0; |
1167 | 1167 | for(i = 0 ; i < carray_count(folder->mb_tab) ; i ++) { |
368 | 368 | struct mailmime_encoded_word ** result, |
369 | 369 | int * p_has_fwd, int * p_missing_closing_quote) |
370 | 370 | { |
371 | #if 0 | |
372 | size_t cur_token; | |
373 | char * charset; | |
374 | int encoding; | |
375 | char * text; | |
376 | size_t end_encoding; | |
377 | char * decoded; | |
378 | size_t decoded_len; | |
379 | struct mailmime_encoded_word * ew; | |
380 | int r; | |
381 | int res; | |
382 | int opening_quote; | |
383 | int end; | |
384 | int has_fwd; | |
385 | int missing_closing_quote; | |
386 | ||
387 | cur_token = * indx; | |
388 | ||
389 | missing_closing_quote = 0; | |
390 | has_fwd = 0; | |
391 | r = mailimf_fws_parse(message, length, &cur_token); | |
392 | if (r == MAILIMF_NO_ERROR) { | |
393 | has_fwd = 1; | |
394 | } | |
395 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | |
396 | res = r; | |
397 | goto err; | |
398 | } | |
399 | ||
400 | opening_quote = FALSE; | |
401 | r = mailimf_char_parse(message, length, &cur_token, '\"'); | |
402 | if (r == MAILIMF_NO_ERROR) { | |
403 | opening_quote = TRUE; | |
404 | } | |
405 | else if (r == MAILIMF_ERROR_PARSE) { | |
406 | /* do nothing */ | |
407 | } | |
408 | else { | |
409 | res = r; | |
410 | goto err; | |
411 | } | |
412 | ||
413 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "=?"); | |
414 | if (r != MAILIMF_NO_ERROR) { | |
415 | res = r; | |
416 | goto err; | |
417 | } | |
418 | ||
419 | r = mailmime_charset_parse(message, length, &cur_token, &charset); | |
420 | if (r != MAILIMF_NO_ERROR) { | |
421 | res = r; | |
422 | goto err; | |
423 | } | |
424 | ||
425 | r = mailimf_char_parse(message, length, &cur_token, '?'); | |
426 | if (r != MAILIMF_NO_ERROR) { | |
427 | res = r; | |
428 | goto free_charset; | |
429 | } | |
430 | ||
431 | r = mailmime_encoding_parse(message, length, &cur_token, &encoding); | |
432 | if (r != MAILIMF_NO_ERROR) { | |
433 | res = r; | |
434 | goto free_charset; | |
435 | } | |
436 | ||
437 | r = mailimf_char_parse(message, length, &cur_token, '?'); | |
438 | if (r != MAILIMF_NO_ERROR) { | |
439 | res = r; | |
440 | goto free_charset; | |
441 | } | |
442 | ||
443 | end = FALSE; | |
444 | end_encoding = cur_token; | |
445 | while (1) { | |
446 | if (end_encoding >= length) | |
447 | break; | |
448 | ||
449 | if (end_encoding + 1 < length) { | |
450 | if ((message[end_encoding] == '?') && (message[end_encoding + 1] == '=')) { | |
451 | end = TRUE; | |
452 | } | |
453 | } | |
454 | ||
455 | if (end) | |
456 | break; | |
457 | ||
458 | end_encoding ++; | |
459 | } | |
460 | ||
461 | decoded_len = 0; | |
462 | decoded = NULL; | |
463 | switch (encoding) { | |
464 | case MAILMIME_ENCODING_B: | |
465 | r = mailmime_base64_body_parse(message, end_encoding, | |
466 | &cur_token, &decoded, | |
467 | &decoded_len); | |
468 | ||
469 | if (r != MAILIMF_NO_ERROR) { | |
470 | res = r; | |
471 | goto free_charset; | |
472 | } | |
473 | break; | |
474 | case MAILMIME_ENCODING_Q: | |
475 | r = mailmime_quoted_printable_body_parse(message, end_encoding, | |
476 | &cur_token, &decoded, | |
477 | &decoded_len, TRUE); | |
478 | ||
479 | if (r != MAILIMF_NO_ERROR) { | |
480 | res = r; | |
481 | goto free_charset; | |
482 | } | |
483 | ||
484 | break; | |
485 | } | |
486 | ||
487 | text = malloc(decoded_len + 1); | |
488 | if (text == NULL) { | |
489 | res = MAILIMF_ERROR_MEMORY; | |
490 | goto free_charset; | |
491 | } | |
492 | ||
493 | if (decoded_len > 0) | |
494 | memcpy(text, decoded, decoded_len); | |
495 | text[decoded_len] = '\0'; | |
496 | ||
497 | mailmime_decoded_part_free(decoded); | |
498 | ||
499 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "?="); | |
500 | #if 0 | |
501 | if (r != MAILIMF_NO_ERROR) { | |
502 | res = r; | |
503 | goto free_encoded_text; | |
504 | } | |
505 | #endif | |
506 | ||
507 | if (opening_quote) { | |
508 | r = mailimf_char_parse(message, length, &cur_token, '\"'); | |
509 | #if 0 | |
510 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | |
511 | res = r; | |
512 | goto free_encoded_text; | |
513 | } | |
514 | #endif | |
515 | if (r == MAILIMF_ERROR_PARSE) { | |
516 | missing_closing_quote = 1; | |
517 | } | |
518 | } | |
519 | ||
520 | /* fix charset */ | |
521 | if (strcasecmp(charset, "utf8") == 0) { | |
522 | free(charset); | |
523 | charset = strdup("utf-8"); | |
524 | } | |
525 | ew = mailmime_encoded_word_new(charset, text); | |
526 | if (ew == NULL) { | |
527 | res = MAILIMF_ERROR_MEMORY; | |
528 | goto free_encoded_text; | |
529 | } | |
530 | ||
531 | * result = ew; | |
532 | * indx = cur_token; | |
533 | * p_has_fwd = has_fwd; | |
534 | * p_missing_closing_quote = missing_closing_quote; | |
535 | ||
536 | return MAILIMF_NO_ERROR; | |
537 | ||
538 | free_encoded_text: | |
539 | mailmime_encoded_text_free(text); | |
540 | free_charset: | |
541 | mailmime_charset_free(charset); | |
542 | err: | |
543 | return res; | |
544 | #else | |
545 | 371 | /* |
546 | 372 | Parse the following, when a unicode character encoding is split. |
547 | 373 | =?UTF-8?B?4Lij4Liw4LmA4Lia4Li04LiU4LiE4Lin4Liy4Lih4Lih4Lix4LiZ4Liq4LmM?= |
820 | 646 | mailmime_decoded_part_free(decoded); |
821 | 647 | free_body: |
822 | 648 | free(body); |
823 | free_encoded_text: | |
824 | 649 | mailmime_encoded_text_free(text); |
825 | 650 | free_charset: |
826 | 651 | mailmime_charset_free(charset); |
827 | 652 | err: |
828 | 653 | return res; |
829 | #endif | |
830 | 654 | } |
831 | 655 | |
832 | 656 | static int mailmime_charset_parse(const char * message, size_t length, |
1223 | 1223 | return "Transaction failed"; |
1224 | 1224 | case MAILSMTP_ERROR_MEMORY: |
1225 | 1225 | return "Memory error"; |
1226 | case MAILSMTP_ERROR_AUTH_NOT_SUPPORTED: | |
1227 | return "Authentication is not supported"; | |
1226 | 1228 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
1227 | 1229 | return "Connection refused"; |
1228 | 1230 | case MAILSMTP_ERROR_STARTTLS_TEMPORARY_FAILURE: |
1230 | 1232 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: |
1231 | 1233 | return "TLS not supported by server"; |
1232 | 1234 | case MAILSMTP_ERROR_AUTH_LOGIN: |
1233 | return "Login failed"; | |
1235 | return "Login failed"; | |
1234 | 1236 | default: |
1235 | 1237 | return "Unknown error code"; |
1236 | 1238 | } |
37 | 37 | #endif |
38 | 38 | |
39 | 39 | #ifndef LIBETPAN_VERSION_MINOR |
40 | #define LIBETPAN_VERSION_MINOR 8 | |
40 | #define LIBETPAN_VERSION_MINOR 9 | |
41 | 41 | #endif |
42 | 42 | |
43 | 43 | #ifndef LIBETPAN_REENTRANT |
46 | 46 | #endif |
47 | 47 | |
48 | 48 | #ifndef LIBETPAN_API_CURRENT |
49 | #define LIBETPAN_API_CURRENT 21 | |
49 | #define LIBETPAN_API_CURRENT 22 | |
50 | 50 | #endif |
51 | 51 | |
52 | 52 | #ifndef LIBETPAN_API_REVISION |
96 | 96 | {"cache", 1, 0, 'c'}, |
97 | 97 | {"flags", 1, 0, 'f'}, |
98 | 98 | {"debug-stream", 0, 0, 'D'}, |
99 | {NULL, 0, 0, 0}, | |
99 | 100 | }; |
100 | 101 | #endif |
101 | 102 | int r; |
53 | 53 | #define BLOCKSIZE 4096 |
54 | 54 | |
55 | 55 | int collect(struct mem_message *message) { |
56 | int len; | |
57 | ||
58 | memset(message, 0, sizeof(struct mem_message)); | |
59 | ||
60 | #ifndef MMAP_UNAVAILABLE | |
56 | 61 | struct stat sb; |
57 | int len; | |
58 | ||
59 | memset(message, 0, sizeof(struct mem_message)); | |
60 | ||
61 | #ifndef MMAP_UNAVAILABLE | |
62 | 62 | /* if stdin is a file whose size is known, try to mmap it */ |
63 | 63 | if (!fstat(0, &sb) && S_ISREG(sb.st_mode) && sb.st_size >= 0) { |
64 | 64 | message->len = sb.st_size; |
285 | 285 | {"no-esmtp", 0, 0, 'E'}, |
286 | 286 | {"ssl", 0, 0, 'L'}, |
287 | 287 | {"lmtp", 0, 0, 'T'}, |
288 | {NULL, 0, 0, 0}, | |
288 | 289 | }; |
289 | 290 | #endif |
290 | 291 |