From 733175aaec70f4466915e1b028de572338911259 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 3 Aug 2001 18:16:59 +0000 Subject: First check to make sure that service->url->authmech is non-NULL before 2001-08-03 Jeffrey Stedfast * providers/smtp/camel-smtp-transport.c (smtp_connect): First check to make sure that service->url->authmech is non-NULL before passing it into strcmp to avoid a segfault. svn path=/trunk/; revision=11618 --- camel/ChangeLog | 4 ++++ camel/providers/smtp/camel-smtp-transport.c | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 8865adad20..e969917624 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,9 @@ 2001-08-03 Jeffrey Stedfast + * providers/smtp/camel-smtp-transport.c (smtp_connect): First + check to make sure that service->url->authmech is non-NULL before + passing it into strcmp to avoid a segfault. + * camel-pgp-context.c (pgp_decrypt): Sigh, if gpg returns '1' it means that the key is bad but it did succeede in decrypting the block so to make users happy (even though I find this a diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 86674fdc2a..92d0abc9b0 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -342,36 +342,36 @@ static gboolean smtp_connect (CamelService *service, CamelException *ex) { CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); - + /* We (probably) need to check popb4smtp before we connect ... */ - if (strcmp(service->url->authmech, "POPB4SMTP") == 0) { + if (service->url->authmech && !strcmp (service->url->authmech, "POPB4SMTP")) { int truth; GByteArray *chal; CamelSasl *sasl; - - sasl = camel_sasl_new("smtp", "POPB4SMTP", service); - chal = camel_sasl_challenge(sasl, NULL, ex); - truth = camel_sasl_authenticated(sasl); + + sasl = camel_sasl_new ("smtp", "POPB4SMTP", service); + chal = camel_sasl_challenge (sasl, NULL, ex); + truth = camel_sasl_authenticated (sasl); if (chal) - g_byte_array_free(chal, TRUE); - camel_object_unref((CamelObject *)sasl); - + g_byte_array_free (chal, TRUE); + camel_object_unref (CAMEL_OBJECT (sasl)); + if (!truth) return FALSE; - - return connect_to_server(service, ex); + + return connect_to_server (service, ex); } - + if (!connect_to_server (service, ex)) return FALSE; - + /* check to see if AUTH is required, if so...then AUTH ourselves */ if (service->url->authmech) { CamelSession *session = camel_service_get_session (service); CamelServiceAuthType *authtype; gboolean authenticated = FALSE; char *errbuf = NULL; - + if (!transport->is_esmtp || !g_hash_table_lookup (transport->authtypes, service->url->authmech)) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("SMTP server %s does not support requested " -- cgit