/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2014 the Claws Mail team
+ * Copyright (C) 1999-2015 the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ *
*/
-
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "claws-features.h"
#endif
-
+
#ifdef USE_GPGME
#include <time.h>
if (!warned)
alertpanel_error(_("PGP Core: Can't get key - no gpg-agent running."));
else
- g_warning(_("PGP Core: Can't get key - no gpg-agent running."));
+ g_warning("PGP Core: Can't get key - no gpg-agent running.");
warned = TRUE;
} else if (gpg_err_code(err) != GPG_ERR_NO_ERROR && gpg_err_code(err) != GPG_ERR_EOF) {
return g_strdup_printf(_("The signature can't be checked - %s"),
case GPG_ERR_NO_ERROR:
g_string_append_printf(siginfo,
_("Good signature from uid \"%s\" (Validity: %s)\n"),
- uid, get_validity_str(key->uids?key->uids->validity:GPGME_VALIDITY_UNKNOWN));
+ uid, get_validity_str((key && key->uids) ? key->uids->validity:GPGME_VALIDITY_UNKNOWN));
break;
case GPG_ERR_KEY_EXPIRED:
g_string_append_printf(siginfo,
case GPG_ERR_SIG_EXPIRED:
g_string_append_printf(siginfo,
_("Expired signature from uid \"%s\" (Validity: %s)\n"),
- uid, get_validity_str(key->uids?key->uids->validity:GPGME_VALIDITY_UNKNOWN));
+ uid, get_validity_str((key && key->uids) ? key->uids->validity:GPGME_VALIDITY_UNKNOWN));
break;
case GPG_ERR_CERT_REVOKED:
g_string_append_printf(siginfo,
}
if (sig->status != GPG_ERR_BAD_SIGNATURE) {
gint j = 1;
- key->uids = key->uids ? key->uids->next : NULL;
- while (key->uids != NULL) {
- g_string_append_printf(siginfo,
- _(" uid \"%s\" (Validity: %s)\n"),
- key->uids->uid,
- key->uids->revoked==TRUE?_("Revoked"):get_validity_str(key->uids->validity));
- j++;
- key->uids = key->uids->next;
+ if (key) {
+ key->uids = key->uids ? key->uids->next : NULL;
+ while (key->uids != NULL) {
+ g_string_append_printf(siginfo,
+ _(" uid \"%s\" (Validity: %s)\n"),
+ key->uids->uid,
+ key->uids->revoked==TRUE?_("Revoked"):get_validity_str(key->uids->validity));
+ j++;
+ key->uids = key->uids->next;
+ }
}
g_string_append_printf(siginfo,_("Owner Trust: %s\n"),
- get_owner_trust_str(key->owner_trust));
+ key ? get_owner_trust_str(key->owner_trust) : _("No key!"));
g_string_append(siginfo,
_("Primary key fingerprint:"));
const char* primary_fpr = NULL;
err = cm_gpgme_data_rewind(plain);
if (err) {
- debug_print("can't seek (%d %d %s)\n", err, errno, strerror(errno));
+ debug_print("can't seek (%d %d %s)\n", err, errno, g_strerror(errno));
}
debug_print("decrypted.\n");
err = cm_gpgme_data_rewind(plain);
if (err) {
- debug_print("can't seek (%d %d %s)\n", err, errno, strerror(errno));
+ debug_print("can't seek (%d %d %s)\n", err, errno, g_strerror(errno));
}
debug_print("decrypted.\n");
if (found_key != NULL) {
gpgme_key_release(key);
gpgme_op_keylist_end(ctx);
- g_warning("ambiguous specification of secret key '%s'\n", keyid);
+ g_warning("ambiguous specification of secret key '%s'", keyid);
privacy_set_error(_("Secret key specification is ambiguous"));
goto bail;
}
gpgme_key_release(found_key);
if (err) {
- g_warning("error adding secret key: %s\n",
+ g_warning("error adding secret key: %s",
gpgme_strerror(err));
privacy_set_error(_("Error setting secret key: %s"),
gpgme_strerror(err));
gchar *ctype_utf8_locale = NULL, *messages_utf8_locale = NULL;
gpgme_engine_info_t engineInfo;
+
+ if (strcmp(prefs_gpg_get_config()->gpg_path, "") != 0 &&
+ access(prefs_gpg_get_config()->gpg_path, X_OK) != -1)
+ gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP,prefs_gpg_get_config()->gpg_path, NULL);
+
if (gpgme_check_version("1.0.0")) {
#ifdef LC_CTYPE
debug_print("setting gpgme CTYPE locale\n");
/* I know it's deprecated, but we don't compile with _LARGEFILE */
cm_gpgme_data_rewind(data);
while ((r = gpgme_data_read(data, buf, BUFSIZ)) > 0) {
- result = realloc(result, r + w);
- if (result == NULL) {
- g_warning("can't allocate memory\n");
+ void *rresult = realloc(result, r + w);
+ if (rresult == NULL) {
+ g_warning("can't allocate memory");
+ if (result != NULL)
+ free(result);
return NULL;
}
+ result = rresult;
memcpy(result+w, buf, r);
w += r;
}