diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-11-10 06:00:54 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-11-10 06:00:54 +0800 |
commit | 7d2baffd501420a0414f686ef0a35d0e71174661 (patch) | |
tree | 81d7ac71789a8d51522ca0bb429d78452a893197 | |
parent | 7f1c4d58ea508131328d7646250688460c1acffa (diff) | |
download | gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar.gz gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar.bz2 gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar.lz gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar.xz gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.tar.zst gsoc2013-evolution-7d2baffd501420a0414f686ef0a35d0e71174661.zip |
If any of the pipe()'s fail, clean up any pipes that may have succeeded.
2001-11-08 Jeffrey Stedfast <fejj@ximian.com>
* camel-pgp-context.c (crypto_exec_with_passwd): If any of the
pipe()'s fail, clean up any pipes that may have succeeded. Also
close the password fds.
svn path=/trunk/; revision=14649
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-pgp-context.c | 34 | ||||
-rw-r--r-- | camel/camel-smime-utils.c | 6 |
3 files changed, 33 insertions, 13 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 1e5a8d7f7b..747b3490a0 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2001-11-08 Jeffrey Stedfast <fejj@ximian.com> + + * camel-pgp-context.c (crypto_exec_with_passwd): If any of the + pipe()'s fail, clean up any pipes that may have succeeded. Also + close the password fds. + 2001-11-09 <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (imap_auth_loop): If we get a diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index a0af559a32..e754fdc670 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -50,7 +50,6 @@ #include <sys/wait.h> #include <termios.h> #include <unistd.h> -#include <signal.h> #include <iconv.h> #include <gal/unicode/gunicode.h> @@ -171,9 +170,9 @@ pgp_get_type_as_string (CamelPgpType type) case CAMEL_PGP_TYPE_PGP2: return "PGP 2.6.x"; case CAMEL_PGP_TYPE_PGP5: - return "PGP 5.x"; + return "PGP 5.0"; case CAMEL_PGP_TYPE_PGP6: - return "PGP 6.x"; + return "PGP 6.5.8"; case CAMEL_PGP_TYPE_GPG: return "GnuPG"; default: @@ -291,25 +290,37 @@ crypto_exec_with_passwd (const char *path, char *argv[], const char *input, int size_t passwd_remaining, passwd_incr, input_remaining, input_incr; size_t size, alloc_size, diag_size, diag_alloc_size; int select_result, read_len, write_len, cancel_fd; - int ip_fds[2], op_fds[2], diag_fds[2]; + int fds[6], *ip_fds, *op_fds, *diag_fds; const char *passwd_next, *input_next; char *buf = NULL, *diag_buf = NULL; fd_set fdset, write_fdset; struct timeval timeout; size_t tmp_len; pid_t child; + int i; if (camel_operation_cancel_check (NULL)) { errno = EINTR; return -1; } - if ((pipe (ip_fds) < 0 ) || - (pipe (op_fds) < 0 ) || - (pipe (diag_fds) < 0 )) { - *diagnostics = g_strdup_printf ("Couldn't create pipe to %s: " - "%s", path, - g_strerror (errno)); + for (i = 0; i < 6; i++) + fds[i] = -1; + + ip_fds = fds; + op_fds = fds + 2; + diag_fds = fds + 4; + + if ((pipe (ip_fds) == -1) || (pipe (op_fds) == -1) || (pipe (diag_fds) == -1)) { + *diagnostics = g_strdup_printf ("Couldn't create pipe to %s: %s", + path, g_strerror (errno)); + + for (i = 0; i < 6; i++) + close (fds[i]); + + close (passwd_fds[0]); + close (passwd_fds[1]); + return -1; } @@ -513,6 +524,9 @@ crypto_exec_with_passwd (const char *path, char *argv[], const char *input, int close (op_fds[0]); close (diag_fds[0]); + if (!passwd_eof_seen) + close (passwd_fds[1]); + *output = buf; if (outlen) *outlen = size; diff --git a/camel/camel-smime-utils.c b/camel/camel-smime-utils.c index 2a5a8d723f..188ed8a17f 100644 --- a/camel/camel-smime-utils.c +++ b/camel/camel-smime-utils.c @@ -99,21 +99,21 @@ camel_smime_is_smime_v3_encrypted (CamelMimePart *mime_part) return TRUE; } - if (header_content_type_is (type, "application", "octent-stream")) { + if (header_content_type_is (type, "application", "octet-stream")) { /* check to see if we have a paremeter called "smime-type" */ param = header_content_type_param (type, "smime-type"); if (param) return TRUE; /* check to see if there is a name param and if it has a smime extension */ - param = header_content_type_param (type, "smime-type"); + param = header_content_type_param (type, "name"); if (param && *param && strlen (param) > 4) { for (i = 0; types[i]; i++) if (!g_strcasecmp (param + strlen (param)-4, types[i])) return TRUE; } - /* check to see if there is a name param and if it has a smime extension */ + /* check to see if there is a filename param and if it has a smime extension */ filename = camel_mime_part_get_filename (mime_part); if (filename && *filename && strlen (filename) > 4) { for (i = 0; types[i]; i++) |