[Pkg-privacy-commits] [pidgin-otr] 30/255: * gtk-dialog.c: * otr-plugin.c: ISO C cleanups (no mixing declarations with code)
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:51:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch experimental
in repository pidgin-otr.
commit 6418a70c0f2f060c0a72a0a0cd6c4e6d24424e25
Author: cypherpunk <cypherpunk>
Date: Thu Jul 26 16:48:10 2007 +0000
* gtk-dialog.c:
* otr-plugin.c: ISO C cleanups (no mixing declarations with code)
* otr-plugin.c: Defend against potential NULL pointer
dereferences
---
ChangeLog | 8 +++++
gtk-dialog.c | 28 +++++++++------
otr-plugin.c | 115 +++++++++++++++++++++++++++++++----------------------------
3 files changed, 87 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b9fd875..f23ea80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-07-26
+
+ * gtk-dialog.c:
+ * otr-plugin.c: ISO C cleanups (no mixing declarations with code)
+
+ * otr-plugin.c: Defend against potential NULL pointer
+ dereferences
+
2007-07-24
* INSTALL: Added information about i18n; added information about
diff --git a/gtk-dialog.c b/gtk-dialog.c
index 8006ee6..a70142c 100644
--- a/gtk-dialog.c
+++ b/gtk-dialog.c
@@ -745,9 +745,13 @@ static void smp_progress_response_cb(GtkDialog *dialog, gint response,
static void smp_secret_response_cb(GtkDialog *dialog, gint response,
SmpResponsePair *smppair)
{
+ ConnContext* context;
+ PurpleConversation *conv;
+ SMPData *smp_data;
+
if (!smppair) return;
- ConnContext* context = smppair->context;
+ context = smppair->context;
if (response == GTK_RESPONSE_ACCEPT) {
GtkEntry* entry = smppair->entry;
char *secret;
@@ -785,9 +789,8 @@ static void smp_secret_response_cb(GtkDialog *dialog, gint response,
gtk_widget_destroy(GTK_WIDGET(dialog));
/* Clean up references to this window */
- PurpleConversation *conv =
- otrg_plugin_context_to_conv(smppair->context, 0);
- SMPData *smp_data = purple_conversation_get_data(conv, "otr-smpdata");
+ conv = otrg_plugin_context_to_conv(smppair->context, 0);
+ smp_data = purple_conversation_get_data(conv, "otr-smpdata");
if (smp_data) {
smp_data->smp_secret_dialog = NULL;
smp_data->smp_secret_smppair = NULL;
@@ -963,6 +966,7 @@ static GtkWidget *create_smp_dialog(const char *title,
char *label_text;
const char *icon_name = NULL;
SmpResponsePair* smppair;
+ char *moremarkup;
icon_name = PIDGIN_STOCK_DIALOG_INFO;
img = gtk_image_new_from_stock(icon_name, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
@@ -1044,7 +1048,7 @@ static GtkWidget *create_smp_dialog(const char *title,
FALSE, 0);
}
- char *moremarkup = g_strdup_printf(
+ moremarkup = g_strdup_printf(
"%s\n\n%s\n\n<a href=\"%s%s\">%s</a>",
_("To authenticate, pick a secret known "
"only to you and your buddy. Enter this secret, then "
@@ -1104,6 +1108,8 @@ static GtkWidget *create_smp_progress_dialog(GtkWindow *parent,
GtkWidget *img = NULL;
char *label_text;
const char *icon_name = NULL;
+ PurpleConversation *conv;
+ SMPData *smp_data;
icon_name = PIDGIN_STOCK_DIALOG_INFO;
img = gtk_image_new_from_stock(icon_name,
@@ -1161,11 +1167,13 @@ static GtkWidget *create_smp_progress_dialog(GtkWindow *parent,
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
- PurpleConversation *conv = otrg_plugin_context_to_conv(context, 0);
- SMPData *smp_data = purple_conversation_get_data(conv, "otr-smpdata");
- smp_data->smp_progress_dialog = dialog;
- smp_data->smp_progress_bar = bar;
- smp_data->smp_progress_label = proglabel;
+ conv = otrg_plugin_context_to_conv(context, 0);
+ smp_data = purple_conversation_get_data(conv, "otr-smpdata");
+ if (smp_data) {
+ smp_data->smp_progress_dialog = dialog;
+ smp_data->smp_progress_bar = bar;
+ smp_data->smp_progress_label = proglabel;
+ }
g_signal_connect(G_OBJECT(dialog), "response",
G_CALLBACK(smp_progress_response_cb),
diff --git a/otr-plugin.c b/otr-plugin.c
index 8e2bab3..95e5106 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -389,9 +389,11 @@ void otrg_plugin_continue_smp(ConnContext *context,
void otrg_plugin_send_default_query(ConnContext *context, void *vaccount)
{
PurpleAccount *account = vaccount;
+ char *msg;
OtrgUiPrefs prefs;
+
otrg_ui_get_prefs(&prefs, account, context->username);
- char *msg = otrl_proto_default_query_msg(context->accountname,
+ msg = otrl_proto_default_query_msg(context->accountname,
prefs.policy);
otrg_plugin_inject_message(account, context->username,
msg ? msg : "?OTRv2?");
@@ -427,6 +429,8 @@ static gboolean process_receiving_im(PurpleAccount *account, char **who,
gboolean res;
const char *accountname;
const char *protocol;
+ ConnContext *context;
+ NextExpectedSMP nextMsg;
if (!who || !*who || !message || !*message)
return 0;
@@ -458,52 +462,54 @@ static gboolean process_receiving_im(PurpleAccount *account, char **who,
/* Keep track of our current progress in the Socialist Millionaires'
* Protocol. */
- ConnContext *context = otrl_context_find(otrg_plugin_userstate, username,
+ context = otrl_context_find(otrg_plugin_userstate, username,
accountname, protocol, 0, NULL, NULL, NULL);
- NextExpectedSMP nextMsg = context->smstate->nextExpected;
-
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT1)
- otrg_plugin_abort_smp(context);
- else {
- otrg_dialog_socialist_millionaires(context);
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT2)
- otrg_plugin_abort_smp(context);
- else {
- otrg_dialog_update_smp(context, 0.6);
- context->smstate->nextExpected = OTRL_SMP_EXPECT4;
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT3)
- otrg_plugin_abort_smp(context);
- else {
- otrg_dialog_update_smp(context, 1.0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT4)
- otrg_plugin_abort_smp(context);
- else {
- otrg_dialog_update_smp(context, 1.0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
- if (tlv) {
- otrg_dialog_update_smp(context, 0.0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ if (context) {
+ nextMsg = context->smstate->nextExpected;
+
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT1)
+ otrg_plugin_abort_smp(context);
+ else {
+ otrg_dialog_socialist_millionaires(context);
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT2)
+ otrg_plugin_abort_smp(context);
+ else {
+ otrg_dialog_update_smp(context, 0.6);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT4;
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT3)
+ otrg_plugin_abort_smp(context);
+ else {
+ otrg_dialog_update_smp(context, 1.0);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT4)
+ otrg_plugin_abort_smp(context);
+ else {
+ otrg_dialog_update_smp(context, 1.0);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
+ if (tlv) {
+ otrg_dialog_update_smp(context, 0.0);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ }
+
+ otrl_tlv_free(tlvs);
}
-
- otrl_tlv_free(tlvs);
free(username);
@@ -529,11 +535,12 @@ static void process_conv_updated(PurpleConversation *conv,
/* See if someone's trying to turn logging on for this conversation,
* and we don't want them to. */
if (type == PURPLE_CONV_UPDATE_LOGGING) {
+ ConnContext *context;
OtrgUiPrefs prefs;
PurpleAccount *account = purple_conversation_get_account(conv);
otrg_ui_get_prefs(&prefs, account, purple_conversation_get_name(conv));
- ConnContext *context = otrg_plugin_conv_to_context(conv);
+ context = otrg_plugin_conv_to_context(conv);
if (context && prefs.avoid_logging_otr &&
context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
conv->logging == TRUE) {
@@ -732,9 +739,6 @@ static void otrg_int_free(gpointer data)
static void otrg_init_mms_table()
{
- mms_table = g_hash_table_new_full(g_str_hash, g_str_equal,
- otrg_str_free, otrg_int_free);
-
/* Hardcoded defaults for maximum message sizes for various
* protocols. These can be overridden in the user's MAXMSGSIZEFNAME
* file. */
@@ -744,8 +748,13 @@ static void otrg_init_mms_table()
} mmsPairs[8] = {{"prpl-msn", 1409}, {"prpl-icq", 2346},
{"prpl-aim", 2343}, {"prpl-yahoo", 832}, {"prpl-gg", 1999},
{"prpl-irc", 417}, {"prpl-oscar", 2343}, {NULL, 0}};
-
int i = 0;
+ gchar *maxmsgsizefile;
+ FILE *mmsf;
+
+ mms_table = g_hash_table_new_full(g_str_hash, g_str_equal,
+ otrg_str_free, otrg_int_free);
+
for (i=0; mmsPairs[i].protid != NULL; i++) {
char* nextprot = g_strdup(mmsPairs[i].protid);
int* nextsize = g_malloc(sizeof(int));
@@ -753,9 +762,8 @@ static void otrg_init_mms_table()
g_hash_table_insert(mms_table, nextprot, nextsize);
}
- gchar *maxmsgsizefile = g_build_filename(purple_user_dir(),
+ maxmsgsizefile = g_build_filename(purple_user_dir(),
MAXMSGSIZEFNAME, NULL);
- FILE *mmsf;
if (maxmsgsizefile) {
mmsf = g_fopen(maxmsgsizefile, "rt");
@@ -764,9 +772,8 @@ static void otrg_init_mms_table()
mms_read_FILEp(mmsf, mms_table);
fclose(mmsf);
}
+ g_free(maxmsgsizefile);
}
-
- g_free(maxmsgsizefile);
}
static void otrg_free_mms_table()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pidgin-otr.git
More information about the Pkg-privacy-commits
mailing list