From 1a459981e901adb26037321960336bc5518010f4 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 23 Aug 2014 13:40:59 -0400 Subject: [PATCH 01/60] Post-release bump to 0.6.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2b2f64d9..00bcd48b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.0]) +m4_define([libinfinity_version], [0.6.1]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From 6d6223e113e52fb2a3b5188da2c09305f38b12ce Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sun, 24 Aug 2014 09:57:21 -0400 Subject: [PATCH 02/60] Explicitly link against libresolv (libinfinity #3) --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 00bcd48b..cfc80a72 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,8 @@ PKG_CHECK_MODULES([inftext], [glib-2.0 >= 2.16 gobject-2.0 >= 2.16 libxml-2.0]) if test $platform = 'win32'; then infinity_LIBS="$infinity_LIBS -lws2_32 -ldnsapi" +else + infinity_LIBS="$infinity_LIBS -lresolv" fi ################################### From 8a72d4da493159b25e1b16adb7bf931a33285d57 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sun, 24 Aug 2014 10:04:39 -0400 Subject: [PATCH 03/60] Release libinfinity 0.6.1 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 768204c7..13b7ab36 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +libinfinity 0.6.1: + * Explicitly link against libresolv on unix-based systems, to avoid + a possible build failure. + libinfinity 0.6.0: * infinoted: Introduced a plugin infrastructure, and ported some of From b868937f4cfc0f4eef6ecfbf5430fe9cdd86c85f Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sun, 24 Aug 2014 10:06:40 -0400 Subject: [PATCH 04/60] Post-release bump to 0.6.2 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cfc80a72..0944cd99 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.1]) +m4_define([libinfinity_version], [0.6.2]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From 97ae9aeef4cd78e4662ccc09f24a9de2d8b5dc7c Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Mon, 25 Aug 2014 04:43:13 +0200 Subject: [PATCH 05/60] Makefile.am: ship the new markdown formatted README --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index c2ca4921..6e38208c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,8 @@ endif SUBDIRS += pixmaps test docs po +EXTRA_DIST = README.md + DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc MAINTAINERCLEANFILES = \ From 7933a5618b800a3a59c8770a40d86d60f1cdcafc Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Wed, 27 Aug 2014 00:57:01 +0200 Subject: [PATCH 06/60] infinoted man page: correct a grammar mistake, escape hyphens --- infinoted/infinoted-0.6.man | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/infinoted/infinoted-0.6.man b/infinoted/infinoted-0.6.man index cef2e2f8..e6b69f88 100644 --- a/infinoted/infinoted-0.6.man +++ b/infinoted/infinoted-0.6.man @@ -32,7 +32,7 @@ The server's private key The server's certificate .TP \fB\-\-certificate\-chain\fR -The certificate chain to the root certificate, if not included in the file given in --certificate-file. +The certificate chain to the root certificate, if not included in the file given in \-\-certificate\-file. .TP \fB\-\-create\-key\fR Creates a new random private key @@ -56,12 +56,12 @@ sessions into the tree periodically. The default directory is ~/.infinote. .TP \fB\-\-plugins\fR=\fIPLUGIN1;PLUGIN2;...\fR -Additional plugins to load, separated by semi-colon. Plugin options can be configured in the configuration file (one section for each plugin), or with the --plugin-parameter option. +Additional plugins to load, separated by semi-colon. Plugin options can be configured in the configuration file (one section for each plugin), or with the \-\-plugin\-parameter option. .TP \fB\-\-plugin-parameter\fR=\fIPLUGIN:KEY:VALUE\fR Sets the option KEY for plugin PLUGIN to the given VALUE. Normally, plugin options are specified in the configuration file, but this command line -option allows to set or override plugin options on the command line. +option allows one to set or override plugin options on the command line. .TP \fB\-P\fR, \fB\-\-password\fR=\fIPASSWORD\fR Require given password on connections From 9a51d6f7b822eb1e0322eb85076456cd9a88f5a9 Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Wed, 27 Aug 2014 01:11:12 +0200 Subject: [PATCH 07/60] infinoted/infinoted-options.c: Fix a grammar mistake. --- infinoted/infinoted-options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infinoted/infinoted-options.c b/infinoted/infinoted-options.c index dc74626b..69af5c63 100644 --- a/infinoted/infinoted-options.c +++ b/infinoted/infinoted-options.c @@ -702,7 +702,7 @@ infinoted_options_load(InfinotedOptions* options, }, { "plugin-parameter", 0, 0, G_OPTION_ARG_STRING_ARRAY, &plugin_parameters, - N_("Allows to override configuration entries for plugins from the " + N_("Allows one to override configuration entries for plugins from the " "command line. The syntax is --plugin-parameter=plugin:key:value, " "where plugin is the name of the plugin for which to override a " "configuration parameter, key is the parameter which to override " From 381364e300371b6cc9eee101730b9bd256b1905c Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Wed, 27 Aug 2014 01:11:51 +0200 Subject: [PATCH 08/60] Refresh pot and pos to pick up a new string. --- po/ca.po | 16 ++++++++-------- po/de.po | 16 ++++++++-------- po/libinfinity-0.6.pot | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/po/ca.po b/po/ca.po index 2737f46c..44511863 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: libinfinity\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" "product=glib&keywords=I18N+L10N&component=general\n" -"POT-Creation-Date: 2014-08-22 11:39-0400\n" +"POT-Creation-Date: 2014-08-27 01:11+0200\n" "PO-Revision-Date: 2009-12-10 07:26+0000\n" "Last-Translator: David Planella \n" "Language-Team: Catalan \n" @@ -264,10 +264,10 @@ msgstr "" #: ../infinoted/infinoted-options.c:705 msgid "" -"Allows to override configuration entries for plugins from the command line. " -"The syntax is --plugin-parameter=plugin:key:value, where plugin is the name " -"of the plugin for which to override a configuration parameter, key is the " -"parameter which to override and value is the new value of the parameter" +"Allows one to override configuration entries for plugins from the command " +"line. The syntax is --plugin-parameter=plugin:key:value, where plugin is the " +"name of the plugin for which to override a configuration parameter, key is " +"the parameter which to override and value is the new value of the parameter" msgstr "" #: ../infinoted/infinoted-options.c:710 @@ -350,12 +350,12 @@ msgid "" "\"allow-tls\" or \"require-tls\"" msgstr "" -#: ../infinoted/infinoted-plugin-manager.c:490 +#: ../infinoted/infinoted-plugin-manager.c:491 #, c-format msgid "Loaded plugin \"%s\" from \"%s\"" msgstr "" -#: ../infinoted/infinoted-plugin-manager.c:534 +#: ../infinoted/infinoted-plugin-manager.c:535 #, c-format msgid "Unloaded plugin \"%s\" from \"%s\"" msgstr "" @@ -875,7 +875,7 @@ msgstr "" msgid "Create _Account" msgstr "" -#: ../libinfgtk/inf-gtk-account-creation-dialog.c:592 +#: ../libinfgtk/inf-gtk-account-creation-dialog.c:596 msgid "Create New Account" msgstr "" diff --git a/po/de.po b/po/de.po index 5e74212d..b8e9fb64 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: libinfinity\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" "product=glib&keywords=I18N+L10N&component=general\n" -"POT-Creation-Date: 2014-08-22 11:39-0400\n" +"POT-Creation-Date: 2014-08-27 01:11+0200\n" "PO-Revision-Date: 2009-11-28 11:36+0000\n" "Last-Translator: Armin Burgmeier \n" "Language-Team: German \n" @@ -275,10 +275,10 @@ msgstr "" #: ../infinoted/infinoted-options.c:705 msgid "" -"Allows to override configuration entries for plugins from the command line. " -"The syntax is --plugin-parameter=plugin:key:value, where plugin is the name " -"of the plugin for which to override a configuration parameter, key is the " -"parameter which to override and value is the new value of the parameter" +"Allows one to override configuration entries for plugins from the command " +"line. The syntax is --plugin-parameter=plugin:key:value, where plugin is the " +"name of the plugin for which to override a configuration parameter, key is " +"the parameter which to override and value is the new value of the parameter" msgstr "" #: ../infinoted/infinoted-options.c:710 @@ -365,12 +365,12 @@ msgstr "" "»%s« ist keine gültige Sicherheitsrichtlinie. Mögliche Werte sind »no-tls«, " "»allow-tls« oder »require-tls«" -#: ../infinoted/infinoted-plugin-manager.c:490 +#: ../infinoted/infinoted-plugin-manager.c:491 #, fuzzy, c-format msgid "Loaded plugin \"%s\" from \"%s\"" msgstr "Erweiterung »%s« (%s) geladen" -#: ../infinoted/infinoted-plugin-manager.c:534 +#: ../infinoted/infinoted-plugin-manager.c:535 #, fuzzy, c-format msgid "Unloaded plugin \"%s\" from \"%s\"" msgstr "Erweiterung »%s« (%s) geladen" @@ -898,7 +898,7 @@ msgstr "Common-Name:" msgid "Create _Account" msgstr "" -#: ../libinfgtk/inf-gtk-account-creation-dialog.c:592 +#: ../libinfgtk/inf-gtk-account-creation-dialog.c:596 msgid "Create New Account" msgstr "" diff --git a/po/libinfinity-0.6.pot b/po/libinfinity-0.6.pot index b773e08c..8700fb4b 100644 --- a/po/libinfinity-0.6.pot +++ b/po/libinfinity-0.6.pot @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" "product=glib&keywords=I18N+L10N&component=general\n" -"POT-Creation-Date: 2014-08-22 11:39-0400\n" +"POT-Creation-Date: 2014-08-27 01:11+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -262,10 +262,10 @@ msgstr "" #: ../infinoted/infinoted-options.c:705 msgid "" -"Allows to override configuration entries for plugins from the command line. " -"The syntax is --plugin-parameter=plugin:key:value, where plugin is the name " -"of the plugin for which to override a configuration parameter, key is the " -"parameter which to override and value is the new value of the parameter" +"Allows one to override configuration entries for plugins from the command " +"line. The syntax is --plugin-parameter=plugin:key:value, where plugin is the " +"name of the plugin for which to override a configuration parameter, key is " +"the parameter which to override and value is the new value of the parameter" msgstr "" #: ../infinoted/infinoted-options.c:710 @@ -348,12 +348,12 @@ msgid "" "\"allow-tls\" or \"require-tls\"" msgstr "" -#: ../infinoted/infinoted-plugin-manager.c:490 +#: ../infinoted/infinoted-plugin-manager.c:491 #, c-format msgid "Loaded plugin \"%s\" from \"%s\"" msgstr "" -#: ../infinoted/infinoted-plugin-manager.c:534 +#: ../infinoted/infinoted-plugin-manager.c:535 #, c-format msgid "Unloaded plugin \"%s\" from \"%s\"" msgstr "" @@ -869,7 +869,7 @@ msgstr "" msgid "Create _Account" msgstr "" -#: ../libinfgtk/inf-gtk-account-creation-dialog.c:592 +#: ../libinfgtk/inf-gtk-account-creation-dialog.c:596 msgid "Create New Account" msgstr "" From 7c2333ca2ef23bf1d5aa148bf582cd2419db6546 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 26 Aug 2014 22:26:30 -0400 Subject: [PATCH 09/60] infinoted: Load default account storage only after loading plugins This allows a plugin to override the account storage without the default account storage having been loaded first, wasting resources and potentially removing permissions for non-matching users. --- infinoted/infinoted-run.c | 69 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/infinoted/infinoted-run.c b/infinoted/infinoted-run.c index 72e55b4f..e345d566 100644 --- a/infinoted/infinoted-run.c +++ b/infinoted/infinoted-run.c @@ -51,23 +51,6 @@ infinoted_run_load_directory(InfinotedRun* run, storage = infd_filesystem_storage_new(startup->options->root_directory); - /* Set an account storage, too. This can be replaced by something more fancy - * by a plugin. */ - account_storage = infd_filesystem_account_storage_new(); - - result = infd_filesystem_account_storage_set_filesystem( - account_storage, - storage, - error - ); - - if(result == FALSE) - { - g_object_unref(account_storage); - g_object_unref(storage); - return FALSE; - } - communication_manager = inf_communication_manager_new(); run->io = inf_standalone_io_new(); @@ -78,17 +61,8 @@ infinoted_run_load_directory(InfinotedRun* run, communication_manager ); - g_object_set( - G_OBJECT(run->directory), - "account-storage", - account_storage, - NULL - ); - infd_directory_enable_chat(run->directory, TRUE); - g_object_unref(storage); - g_object_unref(account_storage); g_object_unref(communication_manager); /* Load server plugins via plugin manager */ @@ -119,6 +93,8 @@ infinoted_run_load_directory(InfinotedRun* run, if(result == FALSE) { + g_object_unref(storage); + g_object_unref(run->plugin_manager); g_object_unref(run->directory); g_object_unref(run->io); @@ -128,6 +104,47 @@ infinoted_run_load_directory(InfinotedRun* run, return FALSE; } + /* Set an account storage, too. This can be replaced by something more fancy + * by a plugin. */ + /* TODO: This filesystem storage should be moved into a plugin, so that + * users can enable it optionally. */ + g_object_get(G_OBJECT(run->directory), "account-storage", &account_storage, NULL); + if(account_storage == NULL) + { + account_storage = infd_filesystem_account_storage_new(); + + result = infd_filesystem_account_storage_set_filesystem( + account_storage, + storage, + error + ); + + if(result == FALSE) + { + g_object_unref(storage); + g_object_unref(account_storage); + + g_object_unref(run->plugin_manager); + g_object_unref(run->directory); + g_object_unref(run->io); + run->plugin_manager = NULL; + run->directory = NULL; + run->io = NULL; + + return FALSE; + } + + g_object_set( + G_OBJECT(run->directory), + "account-storage", + account_storage, + NULL + ); + } + + g_object_unref(storage); + g_object_unref(account_storage); + return TRUE; } From 7dd6fc91596c156f246df217e2ec6c823701cc0c Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Thu, 28 Aug 2014 22:08:35 +0200 Subject: [PATCH 10/60] infinoted man page: correct the usage of --plugins --- infinoted/infinoted-0.6.man | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infinoted/infinoted-0.6.man b/infinoted/infinoted-0.6.man index e6b69f88..2e565cc4 100644 --- a/infinoted/infinoted-0.6.man +++ b/infinoted/infinoted-0.6.man @@ -55,8 +55,8 @@ to this, when the autosave plugin is enabled, it is possible to save sessions into the tree periodically. The default directory is ~/.infinote. .TP -\fB\-\-plugins\fR=\fIPLUGIN1;PLUGIN2;...\fR -Additional plugins to load, separated by semi-colon. Plugin options can be configured in the configuration file (one section for each plugin), or with the \-\-plugin\-parameter option. +\fB\-\-plugins\fR=\fIPLUGIN\fR +Additional plugin to load. Repeat the option on the command-line to specify multiple plugins and semi-colons in the configuration file. Plugin options can be configured in the configuration file (one section for each plugin), or with the \-\-plugin\-parameter option. .TP \fB\-\-plugin-parameter\fR=\fIPLUGIN:KEY:VALUE\fR Sets the option KEY for plugin PLUGIN to the given VALUE. Normally, plugin From b514cb760f4eb4b105ed8122f08bd2346a89b57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiziano=20M=C3=BCller?= Date: Mon, 1 Sep 2014 17:55:37 +0200 Subject: [PATCH 11/60] Build documentation conditionally Building documentation for disabled libraries fails with the following error: ``` libtool: link: cannot find the library `../../../libinfgtk/libinfgtk-0.6.la' or unhandled argument `../../../libinfgtk/libinfgtk-0.6.la' Linking of scanner failed: Makefile:609: recipe for target 'scan-build.stamp' failed ``` --- docs/reference/Makefile.am | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 99344dcf..8db61db7 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -1,4 +1,16 @@ -SUBDIRS = . libinfinity libinftext libinfgtk libinftextgtk libinfinoted-plugin-manager +SUBDIRS = . libinfinity libinftext + +if WITH_INFGTK +SUBDIRS += libinfgtk +endif + +if WITH_INFTEXTGTK +SUBDIRS += libinftextgtk +endif + +if WITH_INFINOTED +SUBDIRS += libinfinoted-plugin-manager +endif # Note that nodist doesn't work here actually because gtk-doc pulls them # in anyway (see content_files in a subdirectory's Makefile.am) From e3460de020268895fda83534a6e37fe502757f7b Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 8 Sep 2014 09:32:52 -0400 Subject: [PATCH 12/60] Fix crash in inf_gtk_browser_store_tree_model_iter_has_child() (gobby #13) This happened if the browser was not open. --- libinfgtk/inf-gtk-browser-store.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libinfgtk/inf-gtk-browser-store.c b/libinfgtk/inf-gtk-browser-store.c index f37a8caf..275d1e99 100644 --- a/libinfgtk/inf-gtk-browser-store.c +++ b/libinfgtk/inf-gtk-browser-store.c @@ -1672,6 +1672,7 @@ inf_gtk_browser_store_tree_model_iter_has_child(GtkTreeModel* model, { InfGtkBrowserStorePrivate* priv; InfGtkBrowserStoreItem* item; + InfBrowserStatus status; InfBrowserIter browser_iter; priv = INF_GTK_BROWSER_STORE_PRIVATE(model); @@ -1683,6 +1684,10 @@ inf_gtk_browser_store_tree_model_iter_has_child(GtkTreeModel* model, browser_iter.node_id = GPOINTER_TO_UINT(iter->user_data2); browser_iter.node = iter->user_data3; + g_object_get(G_OBJECT(item->browser), "status", &status, NULL); + if(status != INF_BROWSER_OPEN) + return FALSE; + if(browser_iter.node == NULL) inf_browser_get_root(item->browser, &browser_iter); From 5444ca6a90da9ade2c80023226016e24287aaced Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Fri, 12 Sep 2014 15:02:29 -0400 Subject: [PATCH 13/60] Fix a crash when a certificate is added into the known hosts file Typically this crash only happened at the point when the connection that presented that certificate was closed. --- libinfgtk/inf-gtk-certificate-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libinfgtk/inf-gtk-certificate-manager.c b/libinfgtk/inf-gtk-certificate-manager.c index 555f6f97..c56161ab 100644 --- a/libinfgtk/inf-gtk-certificate-manager.c +++ b/libinfgtk/inf-gtk-certificate-manager.c @@ -578,7 +578,7 @@ inf_gtk_certificate_manager_response_cb(GtkDialog* dialog, error->message ); } - else if(!cert_equal) + else if(known_cert != NULL && !cert_equal) { g_hash_table_insert(query->known_hosts, hostname, cert); From ced29483b5c244e2563398392b8eb624815f09e1 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Fri, 12 Sep 2014 15:13:40 -0400 Subject: [PATCH 14/60] Release libinfinity 0.6.2 --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 13b7ab36..c05ddc90 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +libinfinity 0.6.2: + * Fix accounts being deleted when a plugin overrides the default + account storage. + * The infinoted manual page has been corrected for the syntax of the + --plugins option. + * A crash has been fixed when a connection is closed for which the + the certificate dialog was shown. + libinfinity 0.6.1: * Explicitly link against libresolv on unix-based systems, to avoid a possible build failure. From 43bc053bb6b7ca5901563c27238b8fcb24be517a Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Fri, 12 Sep 2014 15:20:30 -0400 Subject: [PATCH 15/60] Post-release bump to 0.6.3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0944cd99..d5fc6cb1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.2]) +m4_define([libinfinity_version], [0.6.3]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From 2f583757c73338d8323d3d2d08f580575bdef2e8 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 20 Sep 2014 17:41:49 -0400 Subject: [PATCH 16/60] Write certificate to known hosts file also if it was not present before Regression caused by 37afb068e89fc1aed45f795581904c3aaec34e36. --- libinfgtk/inf-gtk-certificate-manager.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libinfgtk/inf-gtk-certificate-manager.c b/libinfgtk/inf-gtk-certificate-manager.c index c56161ab..ee08ae09 100644 --- a/libinfgtk/inf-gtk-certificate-manager.c +++ b/libinfgtk/inf-gtk-certificate-manager.c @@ -564,11 +564,6 @@ inf_gtk_certificate_manager_response_cb(GtkDialog* dialog, known_cert, &error ); - - if(error == NULL && !cert_equal) - { - cert = inf_cert_util_copy_certificate(cert, &error); - } } if(error != NULL) @@ -578,8 +573,9 @@ inf_gtk_certificate_manager_response_cb(GtkDialog* dialog, error->message ); } - else if(known_cert != NULL && !cert_equal) + else if(!cert_equal) { + cert = inf_cert_util_copy_certificate(cert, &error); g_hash_table_insert(query->known_hosts, hostname, cert); inf_gtk_certificate_manager_write_known_hosts_with_warning( From adbdba88ef292b3f031a4cd348660db9760506a7 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 4 Oct 2014 20:49:28 -0400 Subject: [PATCH 17/60] infinoted-plugin-document-stream: Don't join a user if username is empty --- infinoted/plugins/infinoted-plugin-document-stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/infinoted/plugins/infinoted-plugin-document-stream.c b/infinoted/plugins/infinoted-plugin-document-stream.c index 50858291..79297d2e 100644 --- a/infinoted/plugins/infinoted-plugin-document-stream.c +++ b/infinoted/plugins/infinoted-plugin-document-stream.c @@ -583,7 +583,10 @@ infinoted_plugin_document_stream_subscribe_done( g_object_get(G_OBJECT(proxy), "session", &session, NULL); - if(INF_TEXT_IS_SESSION(session)) + /* User join via document stream only works for chat sessions + * at the moment. */ + if(stream->username == NULL || *stream->username == '\0' || + INF_TEXT_IS_SESSION(session)) { infinoted_plugin_document_stream_start(stream); } From 01f6500cd3dc537444029dc81d4f76389d17f1a0 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 6 Oct 2014 18:05:52 -0400 Subject: [PATCH 18/60] Change the mode parameter for directory creation to 0777 (#6) This especially affects the directory-sync plugin. If other modes are desired, the umask of the process should be set accordingly. This change allows the plugin to create directory that are readable or writable by other users than the process owner. --- infinoted/infinoted-util.c | 2 +- infinoted/plugins/infinoted-plugin-directory-sync.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infinoted/infinoted-util.c b/infinoted/infinoted-util.c index 1c870ecd..88f8ab3d 100644 --- a/infinoted/infinoted-util.c +++ b/infinoted/infinoted-util.c @@ -90,7 +90,7 @@ infinoted_util_create_dirname(const gchar* path, gboolean result; dirname = g_path_get_dirname(path); - result = inf_file_util_create_directory(dirname, 0700, error); + result = inf_file_util_create_directory(dirname, 0777, error); g_free(dirname); return result; diff --git a/infinoted/plugins/infinoted-plugin-directory-sync.c b/infinoted/plugins/infinoted-plugin-directory-sync.c index 87dc2b9d..07abf234 100644 --- a/infinoted/plugins/infinoted-plugin-directory-sync.c +++ b/infinoted/plugins/infinoted-plugin-directory-sync.c @@ -449,7 +449,7 @@ infinoted_plugin_directory_sync_initialize(InfinotedPluginManager* manager, plugin->manager = manager; - if(inf_file_util_create_directory(plugin->directory, 0700, error) == FALSE) + if(inf_file_util_create_directory(plugin->directory, 0777, error) == FALSE) return FALSE; g_signal_connect( From 84b71717c9e97b45455e3ad03a6d384b769307b4 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 9 Oct 2014 11:16:39 -0400 Subject: [PATCH 19/60] Fix check for empty path component in InfdFilesystemStorage Thanks to Jann Horn for reporting this. At the moment I don't think there are any security implications because of this. --- libinfinity/server/infd-directory.c | 17 ++++++++++++----- .../server/infd-filesystem-account-storage.c | 2 +- libinfinity/server/infd-filesystem-storage.c | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index ed303949..deafcea1 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -4275,6 +4275,7 @@ infd_directory_node_explore(InfdDirectory* directory, gchar* path; gsize len; gsize node_len; + gsize sep_len; gsize path_len; guint index; @@ -4308,14 +4309,20 @@ infd_directory_node_explore(InfdDirectory* directory, /* Construct the storage path for this node */ node_len = strlen(storage_node->name); - if(len + 1 + node_len < path_len) + + sep_len = 1; + if(path[len - 1] == '/') sep_len = 0; + + if(len + sep_len + node_len < path_len) { - path_len = len + 1 + node_len; - path = g_realloc(path, path_len + 1); + path_len = len + sep_len + node_len; + path = g_realloc(path, path_len + sep_len); } - path[len] = '/'; - memcpy(path + len + 1, storage_node->name, node_len + 1); + if(sep_len > 0) + path[len] = '/'; + + memcpy(path + len + sep_len, storage_node->name, node_len + 1); /* Read ACL */ sheet_set = infd_directory_read_acl( diff --git a/libinfinity/server/infd-filesystem-account-storage.c b/libinfinity/server/infd-filesystem-account-storage.c index 8c3cc831..a4c09e01 100644 --- a/libinfinity/server/infd-filesystem-account-storage.c +++ b/libinfinity/server/infd-filesystem-account-storage.c @@ -491,7 +491,7 @@ infd_filesystem_account_storage_load_file(InfdFilesystemStorage* storage, doc = infd_filesystem_storage_read_xml_file( storage, "xml", - "accounts", + "/accounts", "inf-acl-account-list", &local_error ); diff --git a/libinfinity/server/infd-filesystem-storage.c b/libinfinity/server/infd-filesystem-storage.c index d2f0ee61..a0ba421e 100644 --- a/libinfinity/server/infd-filesystem-storage.c +++ b/libinfinity/server/infd-filesystem-storage.c @@ -65,10 +65,20 @@ infd_filesystem_storage_verify_path(const gchar* path, gchar** components; gchar** component; - components = g_strsplit(path, "/", 0); + if(path[0] != '/') + { + g_set_error_literal( + error, + infd_filesystem_storage_error_quark, + INFD_FILESYSTEM_STORAGE_ERROR_INVALID_PATH, + _("The path does not start with \"/\"") + ); + } + + components = g_strsplit(path + 1, "/", 0); for(component = components; *component != NULL; ++ component) { - if(*component == '\0' || + if(**component == '\0' || strcmp(*component, ".") == 0 || strcmp(*component, "..") == 0) { g_set_error( @@ -334,7 +344,7 @@ infd_filesystem_storage_get_acl_path(InfdFilesystemStorage* storage, else { full_path = - infd_filesystem_storage_get_path(storage, "xml", "global-acl", error); + infd_filesystem_storage_get_path(storage, "xml", "/global-acl", error); } return full_path; From ccff0177099e769e04164f11e021a2fd74f9e032 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 9 Oct 2014 12:53:46 -0400 Subject: [PATCH 20/60] Fix possible warning when session could not be created --- libinfinity/server/infd-directory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index deafcea1..0ac15022 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -1917,7 +1917,8 @@ infd_directory_session_proxy_ensure(InfdDirectory* directory, g_object_get(G_OBJECT(session), "sync-group", &sync_group, NULL); if(sync_group != NULL && sync_group != sub_group) inf_communication_group_set_target(sync_group, NULL); - g_object_unref(sync_group); + if(sync_group != NULL) + g_object_unref(sync_group); g_object_unref(proxy); } From d42034c44b0ca085499b24ae29aa4c4265a24e56 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 9 Oct 2014 13:19:14 -0400 Subject: [PATCH 21/60] Use length-independent string compare for password check Thanks to Jann Horn for pointing this out. --- infinoted/infinoted-options.c | 4 ++++ infinoted/infinoted-options.h | 1 + infinoted/infinoted-startup.c | 20 +++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/infinoted/infinoted-options.c b/infinoted/infinoted-options.c index 69af5c63..2b1b7161 100644 --- a/infinoted/infinoted-options.c +++ b/infinoted/infinoted-options.c @@ -229,6 +229,9 @@ infinoted_options_validate(InfinotedOptions* options, requires_password = requires_password || options->pam_service != NULL; #endif /* LIBINFINITY_HAVE_PAM */ + if(options->password != NULL) + options->password_len = strlen(options->password); + if(requires_password && options->security_policy == INF_XMPP_CONNECTION_SECURITY_ONLY_UNSECURED) { @@ -971,6 +974,7 @@ infinoted_options_new(const gchar* const* config_files, options->plugins[0] = g_strdup("note-text"); options->plugins[1] = NULL; options->password = NULL; + options->password_len = 0; #ifdef LIBINFINITY_HAVE_PAM options->pam_service = NULL; options->pam_allowed_users = NULL; diff --git a/infinoted/infinoted-options.h b/infinoted/infinoted-options.h index 57773bbf..b5c853bc 100644 --- a/infinoted/infinoted-options.h +++ b/infinoted/infinoted-options.h @@ -45,6 +45,7 @@ struct _InfinotedOptions { gchar** plugins; gchar* password; + gsize password_len; #ifdef LIBINFINITY_HAVE_PAM gchar* pam_service; gchar** pam_allowed_users; diff --git a/infinoted/infinoted-startup.c b/infinoted/infinoted-startup.c index 5fdec85d..3b31ae1d 100644 --- a/infinoted/infinoted-startup.c +++ b/infinoted/infinoted-startup.c @@ -290,6 +290,9 @@ infinoted_startup_sasl_callback(InfSaslContextSession* session, const char* username; const char* password; InfXmppConnection* xmpp; + gchar cmp; + gsize password_len; + gsize i; #ifdef LIBINFINITY_HAVE_PAM const gchar* pam_service; @@ -367,7 +370,22 @@ infinoted_startup_sasl_callback(InfSaslContextSession* session, #endif /* LIBINFINITY_HAVE_PAM */ { g_assert(startup->options->password != NULL); - if(strcmp(startup->options->password, password) == 0) + + /* length-independent string compare */ + cmp = 0; + password_len = strlen(password); + for(i = 0; i < startup->options->password_len; ++i) + { + if(i < password_len) + cmp |= (startup->options->password[i] ^ password[i]); + else + cmp |= (startup->options->password[i] ^ 0x00); + } + + if(startup->options->password_len != password_len) + cmp |= 0xFF; + + if(cmp == 0) { infinoted_log_info( startup->log, From e4c9f274c8f99ad522f1e35c8726d420c99affae Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 9 Oct 2014 14:47:56 -0400 Subject: [PATCH 22/60] Release libinfinity 0.6.3 --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index c05ddc90..d0a06fe4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +libinfinity 0.6.3: + * infinoted: Fix a possible timing attack on the server password + (Jann Horn). + * infinoted: Use mode 0777 instead of 0700 when creating directories + in the directory-sync plugin. + * Write certificates not seen before into the known hosts file. + libinfinity 0.6.2: * Fix accounts being deleted when a plugin overrides the default account storage. From 1555e183d0bc4af7ca23599ef2450d46e4425d6c Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 9 Oct 2014 14:52:39 -0400 Subject: [PATCH 23/60] Post-release bump to 0.6.4 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d5fc6cb1..b305558f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.3]) +m4_define([libinfinity_version], [0.6.4]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From 2845142b5b6153abea986f85c974d6b164068a66 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 18 Oct 2014 13:39:06 -0400 Subject: [PATCH 24/60] inf-name-resolver: Include and (#7) This fixes the build on Mac OS X. --- libinfinity/common/inf-name-resolver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libinfinity/common/inf-name-resolver.c b/libinfinity/common/inf-name-resolver.c index 696d4179..d37bdac1 100644 --- a/libinfinity/common/inf-name-resolver.c +++ b/libinfinity/common/inf-name-resolver.c @@ -61,6 +61,8 @@ # include #else # include +# include +# include #endif #include From a0a94bd95197435c274caff7861818cba26e52f7 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 18 Oct 2014 13:39:57 -0400 Subject: [PATCH 25/60] infinoted-plugin-document-stream: Only use MSG_NOSIGNAL if available (#7) This is a build fix for Mac OS X. --- .../plugins/infinoted-plugin-document-stream.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/infinoted/plugins/infinoted-plugin-document-stream.c b/infinoted/plugins/infinoted-plugin-document-stream.c index 79297d2e..dc41e448 100644 --- a/infinoted/plugins/infinoted-plugin-document-stream.c +++ b/infinoted/plugins/infinoted-plugin-document-stream.c @@ -40,6 +40,8 @@ #include #include +#include "config.h" + typedef enum _InfinotedPluginDocumentStreamStatus { INFINOTED_PLUGIN_DOCUMENT_STREAM_NORMAL, INFINOTED_PLUGIN_DOCUMENT_STREAM_RECEIVING, @@ -882,7 +884,17 @@ infinoted_plugin_document_stream_send_direct( do { - bytes = send(stream->socket, data, len, MSG_NOSIGNAL); + bytes = send( + stream->socket, + data, + len, +#ifdef HAVE_MSG_NOSIGNAL + MSG_NOSIGNAL +#else + 0 +#endif + ); + errcode = errno; if(bytes > 0) @@ -990,7 +1002,11 @@ infinoted_plugin_document_stream_io_in( stream->socket, stream->recv_queue.data + queue_offset, stream->recv_queue.alloc - queue_offset, +#ifdef HAVE_MSG_NOSIGNAL MSG_NOSIGNAL +#else + 0 +#endif ); errcode = errno; From 94ff96e4a4e36c4dd30bbd27a723251878393032 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 18 Oct 2014 13:46:55 -0400 Subject: [PATCH 26/60] Release libinfinity 0.6.4 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index d0a06fe4..860558d2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +libinfinity 0.6.4: + * Build fixes for Mac OS X (#7, Dominyk Tiller). + libinfinity 0.6.3: * infinoted: Fix a possible timing attack on the server password (Jann Horn). From e9c35ca3032df1728b383a077523b95e49057392 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 18 Oct 2014 13:50:14 -0400 Subject: [PATCH 27/60] Post-release bump to 0.6.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b305558f..8aa08e38 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.4]) +m4_define([libinfinity_version], [0.6.5]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From a07f1c836281fe5eeb8666e33c37168dacb36940 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Wed, 22 Oct 2014 13:44:03 -0400 Subject: [PATCH 28/60] Fix possible memory corruption on insert in fixline buffer Also, add a test which reproduces this problem. While the test might well run through even with the buggy version, valgrind will uncover the memory corruption, and in some cases it can lead to a crash or otherwise undesired behaviour. --- libinftext/inf-text-fixline-buffer.c | 6 +++++- test/inf-test-text-fixline.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libinftext/inf-text-fixline-buffer.c b/libinftext/inf-text-fixline-buffer.c index f0b13577..c7daf87b 100644 --- a/libinftext/inf-text-fixline-buffer.c +++ b/libinftext/inf-text-fixline-buffer.c @@ -1181,7 +1181,11 @@ inf_text_fixline_buffer_buffer_insert_text(InfTextBuffer* buffer, ((guint)priv->n_keep - (pos - buf_len)) * sizeof(guint) ); - priv->keep = g_realloc(priv->keep, (pos - buf_len) * sizeof(guint)); + priv->keep = g_realloc( + priv->keep, + ((guint)priv->n_keep - (pos - buf_len)) * sizeof(guint) + ); + priv->n_keep -= (pos - buf_len); inf_text_buffer_insert_chunk(priv->buffer, buf_len, new_chunk, user); diff --git a/test/inf-test-text-fixline.c b/test/inf-test-text-fixline.c index 4da93378..1701721e 100644 --- a/test/inf-test-text-fixline.c +++ b/test/inf-test-text-fixline.c @@ -251,6 +251,8 @@ int main() { "\n\n\n\n", "\n\n", 2, MKBUFINOP(3, "A"), "\n\n\nA\n", "\n\n\nA\n\n" }, { "\n\n\n\n", "\n\n", 2, MKBUFINOP(4, "A"), "\n\n\n\nA", "\n\n\n\nA\n\n" }, + { "\n\n\n\n\n", "\n\n", 2, MKBUFINOP(3, "A"), "\n\n\nA\n\n", "\n\n\nA\n\n" }, + /* 18: */ { "", "\n\n", 2, MKBASEDLOP(0, 1), "", "\n\n" }, { "", "\n\n", 2, MKBASEDLOP(1, 1), "", "\n\n" }, From 567a4a10b5acac175c083ec0ee11ed180eb286b4 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 27 Oct 2014 15:54:17 -0400 Subject: [PATCH 29/60] Fix error message in server log when a client certificate is not trusted --- infinoted/plugins/infinoted-plugin-certificate-auth.c | 2 +- libinfinity/common/inf-error.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/infinoted/plugins/infinoted-plugin-certificate-auth.c b/infinoted/plugins/infinoted-plugin-certificate-auth.c index 312fe7fb..15ffa1e6 100644 --- a/infinoted/plugins/infinoted-plugin-certificate-auth.c +++ b/infinoted/plugins/infinoted-plugin-certificate-auth.c @@ -136,7 +136,7 @@ infinoted_plugin_certificate_auth_certificate_func(InfXmppConnection* xmpp, if(res != GNUTLS_E_SUCCESS) inf_gnutls_set_error(&error, res); else if( (verify_result & GNUTLS_CERT_INVALID) != 0) - inf_gnutls_certificate_verification_set_error(&error, res); + inf_gnutls_certificate_verification_set_error(&error, verify_result); if(error != NULL) { diff --git a/libinfinity/common/inf-error.c b/libinfinity/common/inf-error.c index 2aa02abe..21707637 100644 --- a/libinfinity/common/inf-error.c +++ b/libinfinity/common/inf-error.c @@ -359,6 +359,8 @@ inf_gnutls_certificate_verification_set_error(GError** error, message = _("The certificate has expired"); else if(verify & GNUTLS_CERT_INVALID) message = _("The certificate is invalid"); + else + g_assert_not_reached(); *error = g_error_new_literal( inf_gnutls_certificate_verification_error_quark(), From 2120a2cca633e8f52ea86c9171612c2f1182608d Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 28 Oct 2014 10:27:21 -0400 Subject: [PATCH 30/60] Add a missing status notify in InfXmppConnection --- libinfinity/common/inf-xmpp-connection.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libinfinity/common/inf-xmpp-connection.c b/libinfinity/common/inf-xmpp-connection.c index c0791e3f..45adc6f7 100644 --- a/libinfinity/common/inf-xmpp-connection.c +++ b/libinfinity/common/inf-xmpp-connection.c @@ -723,6 +723,7 @@ inf_xmpp_connection_send_chars(InfXmppConnection* xmpp, * disconnection callback because we wanted to keep the gnutls context * alive until gnutls_record_send() returns. */ inf_xmpp_connection_clear(xmpp); + g_object_notify(G_OBJECT(xmpp), "status"); } } } @@ -3328,6 +3329,8 @@ inf_xmpp_connection_notify_status_cb(InfTcpConnection* tcp, * signal handler) then we can't delete the XML parser here (otherwise * libxml2 crashes, understandably). Instead, just set the status to * closed and clean up after XML parsing in _received_cb(). */ + /* TODO: We should do the full cleanup here, and _received_cb() and + * send_chars should copy/ref everything they need on the stack. */ if(priv->parsing == 0) inf_xmpp_connection_clear(xmpp); From f0857d13e597537148c0a989b639684a7cfd4613 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 28 Oct 2014 10:27:55 -0400 Subject: [PATCH 31/60] Make sure messages are not attempted to be sent on closed connections --- .../inf-communication-central-method.c | 7 +++++- .../inf-communication-registry.c | 24 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libinfinity/communication/inf-communication-central-method.c b/libinfinity/communication/inf-communication-central-method.c index a8ec10e0..d8480278 100644 --- a/libinfinity/communication/inf-communication-central-method.c +++ b/libinfinity/communication/inf-communication-central-method.c @@ -211,6 +211,7 @@ inf_communication_central_method_send_all(InfCommunicationMethod* method, GSList* item; InfXmlConnection* connection; gboolean is_registered; + InfXmlConnectionStatus status; priv = INF_COMMUNICATION_CENTRAL_METHOD_PRIVATE(method); @@ -237,7 +238,11 @@ inf_communication_central_method_send_all(InfCommunicationMethod* method, connection ); - if(is_registered) + /* in case our remove member was not yet called we also check the + * status here, i.e. if we are called in response to an earlier + * handler of the notify::status signal. */ + g_object_get(G_OBJECT(connection), "status", &status, NULL); + if(is_registered && status == INF_XML_CONNECTION_OPEN) { if(connections->next != NULL) { diff --git a/libinfinity/communication/inf-communication-registry.c b/libinfinity/communication/inf-communication-registry.c index 46b23a16..364ebcad 100644 --- a/libinfinity/communication/inf-communication-registry.c +++ b/libinfinity/communication/inf-communication-registry.c @@ -100,6 +100,9 @@ static void inf_communication_registry_send_real(InfCommunicationRegistryEntry* entry, guint num_messages) { + InfXmlConnection* connection; + InfXmlConnectionStatus status; + xmlNodePtr container; xmlNodePtr child; xmlNodePtr xml; @@ -140,6 +143,12 @@ inf_communication_registry_send_real(InfCommunicationRegistryEntry* entry, entry->enqueued_list = container; child = container; + connection = entry->key.connection; + g_object_ref(connection); + + g_object_get(G_OBJECT(connection), "status", &status, NULL); + g_assert(status == INF_XML_CONNECTION_OPEN); + while(child != NULL) { /* TODO: The group could be unset at this point if called from @@ -151,11 +160,7 @@ inf_communication_registry_send_real(InfCommunicationRegistryEntry* entry, { for(xml = child->children; xml != NULL; xml = xml->next) { - inf_communication_method_enqueued( - entry->method, - entry->key.connection, - xml - ); + inf_communication_method_enqueued(entry->method, connection, xml); } } @@ -174,8 +179,15 @@ inf_communication_registry_send_real(InfCommunicationRegistryEntry* entry, * will simply append to entry->enqueued_list, and we will enqueue and * send the messages within the next iteration(s). */ - inf_xml_connection_send(entry->key.connection, xml); + inf_xml_connection_send(connection, xml); + + /* Break if sending the data lead to connection closure */ + g_object_get(G_OBJECT(connection), "status", &status, NULL); + if(status != INF_XML_CONNECTION_OPEN) + break; } + + g_object_unref(connection); } } From f606e2dd646667f94d974cccb1868603aa668b6a Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 28 Oct 2014 13:28:10 -0400 Subject: [PATCH 32/60] Fix possible crash when a connection goes down while broadcasting data --- .../inf-communication-central-method.c | 167 +++++++++--------- 1 file changed, 85 insertions(+), 82 deletions(-) diff --git a/libinfinity/communication/inf-communication-central-method.c b/libinfinity/communication/inf-communication-central-method.c index d8480278..9bed7be0 100644 --- a/libinfinity/communication/inf-communication-central-method.c +++ b/libinfinity/communication/inf-communication-central-method.c @@ -56,6 +56,85 @@ enum { static GObjectClass* parent_class; +static void +inf_communication_central_method_broadcast(InfCommunicationMethod* method, + xmlNodePtr xml, + InfXmlConnection* except) +{ + InfCommunicationCentralMethodPrivate* priv; + InfCommunicationRegistry* registry; + InfCommunicationGroup* group; + GSList* connections; + GSList* item; + InfXmlConnection* connection; + gboolean is_registered; + InfXmlConnectionStatus status; + + priv = INF_COMMUNICATION_CENTRAL_METHOD_PRIVATE(method); + + /* Each of the inf_communication_registry_send() calls can do a callback + * which might possibly screw up our connection list completely. So be safe + * here by copying all relevant information on the stack. */ + g_object_ref(method); + registry = g_object_ref(priv->registry); + group = g_object_ref(priv->group); + + connections = g_slist_copy(priv->connections); + for(item = connections; item != NULL; item = item->next) + g_object_ref(item->data); + + while(connections) + { + connection = INF_XML_CONNECTION(connections->data); + + /* A callback from a prior iteration might have unregistered the + * connection. */ + is_registered = inf_communication_registry_is_registered( + registry, + group, + connection + ); + + /* in case our remove member was not yet called we also check the + * status here, i.e. if we are called in response to a handler of the + * notify::status signal that ran before ours. */ + g_object_get(G_OBJECT(connection), "status", &status, NULL); + if(is_registered && + status == INF_XML_CONNECTION_OPEN && + connection != except) + { + if(connections->next != NULL) + { + /* Keep ownership of XML if there might be more connections we should + * send it to. */ + inf_communication_registry_send( + registry, + group, + connection, + xmlCopyNode(xml, 1) + ); + } + else + { + /* Pass ownership of XML if this is definitely the last connection + * in the list. */ + inf_communication_registry_send(registry, group, connection, xml); + xml = NULL; + } + } + + g_object_unref(connection); + connections = g_slist_delete_link(connections, connections); + } + + g_object_unref(method); + g_object_unref(registry); + g_object_unref(group); + + if(xml != NULL) + xmlFreeNode(xml); +} + static void inf_communication_central_method_notify_status_cb(GObject* object, GParamSpec* pspec, @@ -204,76 +283,7 @@ static void inf_communication_central_method_send_all(InfCommunicationMethod* method, xmlNodePtr xml) { - InfCommunicationCentralMethodPrivate* priv; - InfCommunicationRegistry* registry; - InfCommunicationGroup* group; - GSList* connections; - GSList* item; - InfXmlConnection* connection; - gboolean is_registered; - InfXmlConnectionStatus status; - - priv = INF_COMMUNICATION_CENTRAL_METHOD_PRIVATE(method); - - /* Each of the inf_communication_registry_send() calls can do a callback - * which might possibly screw up our connection list completely. So be safe - * here by copying all relevant information on the stack. */ - g_object_ref(method); - registry = g_object_ref(priv->registry); - group = g_object_ref(priv->group); - - connections = g_slist_copy(priv->connections); - for(item = connections; item != NULL; item = item->next) - g_object_ref(item->data); - - while(connections) - { - connection = INF_XML_CONNECTION(connections->data); - - /* A callback from a prior iteration might have unregistered the - * connection. */ - is_registered = inf_communication_registry_is_registered( - registry, - group, - connection - ); - - /* in case our remove member was not yet called we also check the - * status here, i.e. if we are called in response to an earlier - * handler of the notify::status signal. */ - g_object_get(G_OBJECT(connection), "status", &status, NULL); - if(is_registered && status == INF_XML_CONNECTION_OPEN) - { - if(connections->next != NULL) - { - /* Keep ownership of XML if there might be more connections we should - * send it to. */ - inf_communication_registry_send( - registry, - group, - connection, - xmlCopyNode(xml, 1) - ); - } - else - { - /* Pass ownership of XML if this is definitely the last connection - * in the list. */ - inf_communication_registry_send(registry, group, connection, xml); - xml = NULL; - } - } - - g_object_unref(connection); - connections = g_slist_delete_link(connections, connections); - } - - g_object_unref(method); - g_object_unref(registry); - g_object_unref(group); - - if(xml != NULL) - xmlFreeNode(xml); + inf_communication_central_method_broadcast(method, xml, NULL); } static void @@ -324,18 +334,11 @@ inf_communication_central_method_received(InfCommunicationMethod* method, if(priv->is_publisher && scope == INF_COMMUNICATION_SCOPE_GROUP) { - for(item = priv->connections; item != NULL; item = item->next) - { - if(item->data != connection) - { - inf_communication_registry_send( - priv->registry, - priv->group, - INF_XML_CONNECTION(item->data), - xmlCopyNode(xml, 1) - ); - } - } + inf_communication_central_method_broadcast( + method, + xmlCopyNode(xml, 1), + connection + ); } g_object_unref(method); From 0ea3d867cdedad32483fe7507a41680ab7e704ef Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 28 Oct 2014 13:39:53 -0400 Subject: [PATCH 33/60] Fix a memory leak in the plugin manager Conflicts: infinoted/infinoted-plugin-manager.c --- infinoted/infinoted-plugin-manager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infinoted/infinoted-plugin-manager.c b/infinoted/infinoted-plugin-manager.c index b0edcc7c..4c2c3e2e 100644 --- a/infinoted/infinoted-plugin-manager.c +++ b/infinoted/infinoted-plugin-manager.c @@ -781,6 +781,8 @@ infinoted_plugin_manager_finalize(GObject* object) g_hash_table_unref(priv->connections); g_hash_table_unref(priv->sessions); + g_free(priv->path); + G_OBJECT_CLASS(parent_class)->finalize(object); } From 4fd9cadf82d2ee24d9c966ad30c64db3aa83696f Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 6 Jan 2015 13:30:37 +0100 Subject: [PATCH 34/60] Fix assertion failure when directory without storage is disposed --- libinfinity/server/infd-directory.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index 0ac15022..2d4322c1 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -8568,9 +8568,12 @@ infd_directory_dispose(GObject* object) infd_directory_node_free(directory, priv->root); priv->root = NULL; - g_assert(priv->orig_root_acl != NULL); - inf_acl_sheet_set_free(priv->orig_root_acl); - priv->orig_root_acl = NULL; + /* Can be NULL, for example when no storage is set */ + if(priv->orig_root_acl != NULL) + { + inf_acl_sheet_set_free(priv->orig_root_acl); + priv->orig_root_acl = NULL; + } g_hash_table_destroy(priv->nodes); priv->nodes = NULL; From 70913b5b64a85b9d5e0870b73cafff0f9c0aed55 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 6 Jan 2015 14:13:38 +0100 Subject: [PATCH 35/60] InfdDirectory: Fail add-subdirectory request if name already exists --- libinfinity/server/infd-directory.c | 74 ++++++++++++++++++----------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index 2d4322c1..a581aefc 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -4471,6 +4471,7 @@ infd_directory_node_add_subdirectory(InfdDirectory* directory, InfdDirectoryNode* node; gboolean result; gchar* path; + GError* local_error; InfBrowserIter parent_iter; InfBrowserIter iter; @@ -4481,11 +4482,17 @@ infd_directory_node_add_subdirectory(InfdDirectory* directory, priv = INFD_DIRECTORY_PRIVATE(directory); - if(!infd_directory_node_is_name_available(directory, parent, name, error)) - { - return NULL; - } - else + local_error = NULL; + node = NULL; + + infd_directory_node_is_name_available( + directory, + parent, + name, + &local_error + ); + + if(local_error == NULL) { infd_directory_node_make_path(parent, name, &path, NULL); @@ -4495,37 +4502,46 @@ infd_directory_node_add_subdirectory(InfdDirectory* directory, result = TRUE; g_free(path); - if(result == FALSE) return NULL; + if(result == TRUE) + { + node = infd_directory_node_new_subdirectory( + directory, + parent, + priv->node_counter++, + g_strdup(name), + sheet_set, + TRUE + ); - node = infd_directory_node_new_subdirectory( - directory, - parent, - priv->node_counter++, - g_strdup(name), - sheet_set, - TRUE - ); + node->shared.subdir.explored = TRUE; - node->shared.subdir.explored = TRUE; + infd_directory_node_register(directory, node, request, NULL, seq); - infd_directory_node_register(directory, node, request, NULL, seq); + parent_iter.node_id = parent->id; + parent_iter.node = parent; + iter.node_id = node->id; + iter.node = node; - parent_iter.node_id = parent->id; - parent_iter.node = parent; - iter.node_id = node->id; - iter.node = node; + inf_request_finish( + INF_REQUEST(request), + inf_request_result_make_add_node( + INF_BROWSER(directory), + &parent_iter, + &iter + ) + ); + } + } - inf_request_finish( - INF_REQUEST(request), - inf_request_result_make_add_node( - INF_BROWSER(directory), - &parent_iter, - &iter - ) - ); + if(local_error != NULL) + { + g_assert(node == NULL); - return node; + inf_request_fail(INF_REQUEST(request), local_error); + g_propagate_error(error, local_error); } + + return node; } static gboolean From 66432aa0b9b48906db8c258cc70dec4c012787d5 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 6 Jan 2015 16:48:10 +0100 Subject: [PATCH 36/60] Fix a crash when sending unsubscribe message causes connection failure --- libinfinity/client/infc-session-proxy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libinfinity/client/infc-session-proxy.c b/libinfinity/client/infc-session-proxy.c index 8c635736..5fe12c87 100644 --- a/libinfinity/client/infc-session-proxy.c +++ b/libinfinity/client/infc-session-proxy.c @@ -120,7 +120,11 @@ infc_session_proxy_unsubscribe_connection(InfcSessionProxy* proxy) ); } - infc_session_proxy_release_connection(proxy); + /* If an error occurs while sending the "session-unsubscribe" message, the + * connection is released already as a result of the connection status + * notify handler, so we need another check here. */ + if(priv->connection != NULL) + infc_session_proxy_release_connection(proxy); } /* From 7b4efd3ec7fcf7ca44550d7b29e8448cd8fb5f44 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Wed, 14 Jan 2015 15:28:16 -0500 Subject: [PATCH 37/60] Check whether we need -lresolv for res_query() (gobby #23) Some systems such as FreeBSD have res_query() within libc, and passing -lresolv to the linker makes it fail because libresolv does not exist. --- configure.ac | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8aa08e38..130d4c7f 100644 --- a/configure.ac +++ b/configure.ac @@ -125,7 +125,41 @@ PKG_CHECK_MODULES([inftext], [glib-2.0 >= 2.16 gobject-2.0 >= 2.16 libxml-2.0]) if test $platform = 'win32'; then infinity_LIBS="$infinity_LIBS -lws2_32 -ldnsapi" else - infinity_LIBS="$infinity_LIBS -lresolv" + # Check whether we need libresolv for res_query() + # Can't use AC_SEARCH_LIBS because res_query is a macro defined in + # resolv.h + AC_MSG_CHECKING(for res_query) + AC_TRY_LINK( + [ + #include + #include + #include + #include + ], + [res_query(NULL, 0, 0, NULL, 0);], + [ + # res_init() available in libc + AC_MSG_RESULT(yes) + ], + [ + LIBS="-lresolv" + AC_TRY_LINK( + [ + #include + #include + #include + #include + ], + [res_query(NULL, 0, 0, NULL, 0);], + [ + AC_MSG_RESULT(in libresolv) + LIBS="" + infinity_LIBS="$infinity_LIBS -lresolv" # res_init available in libresolv + ], + [AC_MSG_ERROR(res_query not provided by either libc or libresolv)] + ) + ] + ) fi ################################### From 1a0ff8091afdfe831d317d10c377a8a025ea259d Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 17 Jan 2015 20:19:38 -0500 Subject: [PATCH 38/60] Release libinfinity 0.6.5 --- NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 860558d2..41186b30 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +libinfinity 0.6.5: + * Fix memory corruption in InfTextFixlineBuffer. + * infinoted: Fix error message in server log when a client certificate + is not trusted. + * Fix various crashes related to sending data to already closed + connections. + * Build fix when res_query is provided by libc, not libresolv, such + as on FreeBSD (gobby #23, Samantha Michelle Smith). + libinfinity 0.6.4: * Build fixes for Mac OS X (#7, Dominyk Tiller). From 0ce00121225662125b2ae4e48ff5d9f712e86a70 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 17 Jan 2015 20:33:25 -0500 Subject: [PATCH 39/60] Post-release bump to 0.6.6 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 130d4c7f..97eb9cdb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.5]) +m4_define([libinfinity_version], [0.6.6]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From 8990cf98ab43f3aca6a7bf12e9608b0e2e9b5c70 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Fri, 3 Apr 2015 13:04:24 -0400 Subject: [PATCH 40/60] Fix a crash when the server explicitly changes client account to default --- libinfinity/client/infc-browser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libinfinity/client/infc-browser.c b/libinfinity/client/infc-browser.c index 940c4b8f..a35016be 100644 --- a/libinfinity/client/infc-browser.c +++ b/libinfinity/client/infc-browser.c @@ -4309,7 +4309,8 @@ infc_browser_handle_change_acl_account(InfcBrowser* browser, if(existing_account != NULL) { - if(strcmp(account->name, existing_account->name) != 0) + if(account->name == NULL || existing_account->name == NULL || + strcmp(account->name, existing_account->name) != 0) { /* Update account name, if it has changed */ g_free(existing_account->name); From 9b009160dd658fe9272d69025a8225b02eafb8de Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 30 Apr 2015 21:37:23 -0400 Subject: [PATCH 41/60] Fix create_end_iter() implementation in InfTextFixlineBuffer --- libinftext/inf-text-fixline-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libinftext/inf-text-fixline-buffer.c b/libinftext/inf-text-fixline-buffer.c index c7daf87b..4577979b 100644 --- a/libinftext/inf-text-fixline-buffer.c +++ b/libinftext/inf-text-fixline-buffer.c @@ -1374,7 +1374,7 @@ inf_text_fixline_buffer_buffer_create_end_iter(InfTextBuffer* buffer) } iter = g_slice_new(InfTextBufferIter); - iter->base_iter = NULL; + iter->base_iter = base_iter; } return iter; From da06a82642c1d2d0d5a44f1ea3f62ad0b2b22c9a Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sun, 3 May 2015 17:07:46 -0400 Subject: [PATCH 42/60] Fix insert/erase notifications in InfTextFixlineBuffer The notifications were missing when the fixline buffer was modified directly with the API, and not in response to modifications to the underlying base buffer. --- libinftext/inf-text-fixline-buffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libinftext/inf-text-fixline-buffer.c b/libinftext/inf-text-fixline-buffer.c index 4577979b..2b3888ea 100644 --- a/libinftext/inf-text-fixline-buffer.c +++ b/libinftext/inf-text-fixline-buffer.c @@ -1203,6 +1203,9 @@ inf_text_fixline_buffer_buffer_insert_text(InfTextBuffer* buffer, fixline_buffer ); + /* Notify */ + inf_text_buffer_text_inserted(buffer, pos, chunk, user); + /* Keep the number of lines at the end fixed */ inf_text_fixline_buffer_fix_lines(fixline_buffer); } @@ -1215,6 +1218,7 @@ inf_text_fixline_buffer_buffer_erase_text(InfTextBuffer* buffer, { InfTextFixlineBuffer* fixline_buffer; InfTextFixlineBufferPrivate* priv; + InfTextChunk* erased_content; guint buf_len; fixline_buffer = INF_TEXT_FIXLINE_BUFFER(buffer); @@ -1227,6 +1231,8 @@ inf_text_fixline_buffer_buffer_erase_text(InfTextBuffer* buffer, fixline_buffer ); + erased_content = inf_text_buffer_get_slice(buffer, pos, len); + if(pos + len > buf_len) { if(pos > buf_len) @@ -1287,6 +1293,10 @@ inf_text_fixline_buffer_buffer_erase_text(InfTextBuffer* buffer, fixline_buffer ); + /* Notify */ + inf_text_buffer_text_erased(buffer, pos, erased_content, user); + inf_text_chunk_free(erased_content); + /* Keep the number of lines at the end fixed */ inf_text_fixline_buffer_fix_lines(fixline_buffer); } From fb0c8532694476f3f624f66eb12becf851147e27 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 4 May 2015 20:31:12 -0400 Subject: [PATCH 43/60] fixline buffer: Fix crash when iterating backwards through empty base buffer --- libinftext/inf-text-fixline-buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libinftext/inf-text-fixline-buffer.c b/libinftext/inf-text-fixline-buffer.c index 2b3888ea..2e53a018 100644 --- a/libinftext/inf-text-fixline-buffer.c +++ b/libinftext/inf-text-fixline-buffer.c @@ -1484,7 +1484,8 @@ inf_text_fixline_buffer_buffer_iter_prev(InfTextBuffer* buffer, if(iter->keep_begin == 0) { iter->base_iter = inf_text_buffer_create_end_iter(priv->buffer); - g_assert(iter->base_iter != NULL); + if(iter->base_iter == NULL) + return FALSE; return TRUE; } From 244c7e8d69b98330ac7a285922c6fcb0a167ae20 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 5 May 2015 20:45:45 -0400 Subject: [PATCH 44/60] Update caret position when only updating fixline state When the user inserts some newlines that are "swallowed" by the fixline buffer, then still advance the user's cursor such that newly to-be-written text is inserted after the imaginary newline. --- libinftext/inf-text-fixline-buffer.c | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libinftext/inf-text-fixline-buffer.c b/libinftext/inf-text-fixline-buffer.c index 2e53a018..c4eb3268 100644 --- a/libinftext/inf-text-fixline-buffer.c +++ b/libinftext/inf-text-fixline-buffer.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -577,6 +578,9 @@ inf_text_fixline_buffer_text_inserted_cb(InfTextBuffer* buffer, guint buffer_length; guint end; + guint user_pos; + gint user_len; + InfTextChunk* new_chunk; gchar stext[16]; gchar* text; @@ -633,11 +637,35 @@ inf_text_fixline_buffer_text_inserted_cb(InfTextBuffer* buffer, g_free(priv->keep); priv->keep = NULL; } + + /* TODO: We don't know whether this was an insert-caret or not, but + * assume for now that it was. Advance the user's caret, which would + * account for the added newlines that we swallowed above. */ + /* TODO: A better way might be to just skip this special handling + * altogether and just actually propagate this change. */ + user_pos = inf_text_user_get_caret_position(INF_TEXT_USER(user)); + user_len = inf_text_user_get_selection_length(INF_TEXT_USER(user)); + + inf_text_move_operation_transform_insert( + pos, + chunk_length, + &user_pos, + &user_len, + FALSE + ); + + inf_text_user_set_selection( + INF_TEXT_USER(user), + user_pos, + user_len, + TRUE + ); } else { if(pos > end) { + /* TODO: Should we handle caret updates here as well? */ g_assert(priv->n_keep < 0); g_assert((guint)(-priv->n_keep) >= pos - end); @@ -701,6 +729,9 @@ inf_text_fixline_buffer_text_erased_cb(InfTextBuffer* buffer, guint use_keep; InfTextChunk* new_chunk; + guint user_pos; + gint user_len; + priv = INF_TEXT_FIXLINE_BUFFER_PRIVATE(user_data); chunk_length = inf_text_chunk_get_length(chunk); @@ -759,6 +790,28 @@ inf_text_fixline_buffer_text_erased_cb(InfTextBuffer* buffer, use_keep ); } + + /* TODO: We don't know whether this was an erase-caret or not, but + * assume for now that it was. Advance the user's caret, which would + * account for the removed newlines that we swallowed above. */ + /* TODO: A better way might be to just skip this special handling + * altogether and just actually propagate this change. */ + user_pos = inf_text_user_get_caret_position(INF_TEXT_USER(user)); + user_len = inf_text_user_get_selection_length(INF_TEXT_USER(user)); + + inf_text_move_operation_transform_delete( + pos, + chunk_length, + &user_pos, + &user_len + ); + + inf_text_user_set_selection( + INF_TEXT_USER(user), + user_pos, + user_len, + TRUE + ); } else { @@ -773,6 +826,7 @@ inf_text_fixline_buffer_text_erased_cb(InfTextBuffer* buffer, else if(pos + chunk_length > end) { /* Propagate partly */ + /* TODO: Should we handle caret updates here as well? */ g_assert(priv->n_keep < 0); g_assert(chunk_length - (end - pos) <= (guint)(-priv->n_keep)); From 06fa9455c687a67e4fc2c2f201817c64c73a3fcf Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 11 May 2015 22:59:34 -0400 Subject: [PATCH 45/60] Fix expired certificate validation (gobby #61) --- libinfgtk/inf-gtk-certificate-manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libinfgtk/inf-gtk-certificate-manager.c b/libinfgtk/inf-gtk-certificate-manager.c index ee08ae09..bc70e75a 100644 --- a/libinfgtk/inf-gtk-certificate-manager.c +++ b/libinfgtk/inf-gtk-certificate-manager.c @@ -710,9 +710,11 @@ inf_gtk_certificate_manager_certificate_func(InfXmppConnection* connection, if(ret != GNUTLS_E_SUCCESS) inf_gnutls_set_error(&error, ret); - else if(verify & GNUTLS_CERT_INVALID) - inf_gnutls_certificate_verification_set_error(&error, verify); } + + if(error == NULL) + if(verify & GNUTLS_CERT_INVALID) + inf_gnutls_certificate_verification_set_error(&error, verify); } /* Look up the host in our database of pinned certificates if we could not From 3862714b942fe626308f06e01730df7b48921faf Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 12 May 2015 20:55:41 -0400 Subject: [PATCH 46/60] Fix make distcheck for recent automake versions Recent automake versions run with a more restrictive umask, so that the version.xml files are created with read-only permissions. This fails when trying to override them, so remove them explicitly before. --- docs/reference/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 8db61db7..9028af56 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -19,9 +19,11 @@ nodist_noinst_DATA = version.xml api_version.xml # Remove the trailing newline of the version files, to have the entities # in the docbook XML substituted without it. version.xml: version.xml.in + rm -f version.xml echo -n `cat version.xml.in` > version.xml api_version.xml: api_version.xml.in + rm -f api_version.xml echo -n `cat api_version.xml.in` > api_version.xml CLEANFILES = version.xml api_version.xml From a5bc24e87714d3c3fa75711c5d06b9b8e4c81d53 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 12 May 2015 20:12:52 -0400 Subject: [PATCH 47/60] Release libinfinity 0.6.6 --- NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 41186b30..8727ded3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +libinfinity 0.6.6: + * Fix certificates being only verified for expiration and other + criteria such as weak algorithms if the CA is not trusted. + (gobby #61) + * Fix some assertion failures and inconsistencies in + InfTextFixlineBuffer. + * Fix a client-side crash when the server shuts down ordinarily + while still connected. + libinfinity 0.6.5: * Fix memory corruption in InfTextFixlineBuffer. * infinoted: Fix error message in server log when a client certificate From 4522baf6a975f38e6874c90695b00af0d2854dfc Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 12 May 2015 20:58:49 -0400 Subject: [PATCH 48/60] Post-release bump to 0.6.7 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 97eb9cdb..d924945b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.6]) +m4_define([libinfinity_version], [0.6.7]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From cf4588011a5023af36d6393f1f724a11742b84f1 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Fri, 22 May 2015 19:22:26 -0400 Subject: [PATCH 49/60] Fix a possible crash when removing a browser entry --- libinfgtk/inf-gtk-browser-store.c | 5 +++++ libinfgtk/inf-gtk-browser-view.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/libinfgtk/inf-gtk-browser-store.c b/libinfgtk/inf-gtk-browser-store.c index 275d1e99..ef626060 100644 --- a/libinfgtk/inf-gtk-browser-store.c +++ b/libinfgtk/inf-gtk-browser-store.c @@ -520,6 +520,11 @@ inf_gtk_browser_store_remove_item(InfGtkBrowserStore* store, /* Note we need to reset the browser before we unlink because * inf_gtk_browser_store_item_set_browser() requires item still being * linked for change notifications. */ + /* TODO: This is a bit cumbersome. A better way might be to be able for + * the iter parameter to be NULL to indicate that an entry with + * its browser has been deleted. However, this would still need to do + * lots of the unregistration that is now happening in + * inf_gtk_browser_store_item_set_browser(). */ if(item->browser != NULL) { inf_gtk_browser_store_item_set_browser(store, item, path, NULL); diff --git a/libinfgtk/inf-gtk-browser-view.c b/libinfgtk/inf-gtk-browser-view.c index ec3504f4..fa4b8ccf 100644 --- a/libinfgtk/inf-gtk-browser-view.c +++ b/libinfgtk/inf-gtk-browser-view.c @@ -2073,6 +2073,12 @@ inf_gtk_browser_view_status_icon_data_func(GtkTreeViewColumn* column, switch(status) { + case INF_GTK_BROWSER_MODEL_INVALID: + /* This can happen when the cell data func is called between the + * resetting of an item and its removal from the tree. But in any case + * it will be removed soon, so no need to do anything here. */ + stock_id = NULL; + break; case INF_GTK_BROWSER_MODEL_DISCONNECTED: case INF_GTK_BROWSER_MODEL_DISCOVERED: case INF_GTK_BROWSER_MODEL_RESOLVING: @@ -2326,6 +2332,11 @@ inf_gtk_browser_view_status_data_func(GtkTreeViewColumn* column, switch(status) { + case INF_GTK_BROWSER_MODEL_INVALID: + /* This can happen when the cell data func is called between the + * resetting of an item and its removal from the tree. But in any case + * it will be removed soon, so no need to do anything here. */ + break; case INF_GTK_BROWSER_MODEL_DISCOVERED: case INF_GTK_BROWSER_MODEL_DISCONNECTED: g_object_set( From 822b227c662e5fcaab3c1bdfdf224eebaefe7728 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sat, 23 May 2015 14:39:59 -0400 Subject: [PATCH 50/60] Fix session becoming inconsistent with active local users during subscription When the server sends the vector time of local users during subscription, it now sends the last send vector instead of the real value of the user time, so that subsequent state vector diffs are consistent for the newly joined client. Conflicts: libinfinity/adopted/inf-adopted-session.c --- libinfinity/adopted/inf-adopted-session.c | 34 ++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/libinfinity/adopted/inf-adopted-session.c b/libinfinity/adopted/inf-adopted-session.c index 51a3901b..33216754 100644 --- a/libinfinity/adopted/inf-adopted-session.c +++ b/libinfinity/adopted/inf-adopted-session.c @@ -1397,10 +1397,16 @@ inf_adopted_session_set_xml_user_props(InfSession* session, guint n_params, xmlNodePtr xml) { + InfAdoptedSessionPrivate* priv; const GParameter* time; InfAdoptedStateVector* vector; gchar* time_string; + const GParameter* id_param; + guint id; + GSList* item; + InfAdoptedSessionLocalUser* local_user; + INF_SESSION_CLASS(parent_class)->set_xml_user_props( session, params, @@ -1408,10 +1414,36 @@ inf_adopted_session_set_xml_user_props(InfSession* session, xml ); + priv = INF_ADOPTED_SESSION_PRIVATE(INF_ADOPTED_SESSION(session)); + time = inf_session_lookup_user_property(params, n_params, "vector"); if(time != NULL) { - vector = (InfAdoptedStateVector*)g_value_get_boxed(&time->value); + /* If this is a local user, use last_send_vector instead of the user's + * vector, so that subsequent differential updates are consistent. */ + vector = NULL; + id_param = inf_session_lookup_user_property(params, n_params, "id"); + + if(id_param != NULL) + { + id = g_value_get_uint(&id_param->value); + for(item = priv->local_users; item != NULL; item = item->next) + { + local_user = (InfAdoptedSessionLocalUser*)item->data; + if(inf_user_get_id(INF_USER(local_user->user)) == id) + { + vector = local_user->last_send_vector; + break; + } + } + } + + if(vector == NULL) + { + /* remote user, or a user join request */ + vector = (InfAdoptedStateVector*)g_value_get_boxed(&time->value); + } + time_string = inf_adopted_state_vector_to_string(vector); inf_xml_util_set_attribute(xml, "time", time_string); g_free(time_string); From d17398a0f850a79ffbe78c10bbe8ebfd0cd5e63c Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Wed, 27 May 2015 21:12:28 -0400 Subject: [PATCH 51/60] InfdDirectory: Fix error reply to client when session proxy cannot be created --- libinfinity/server/infd-directory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index a581aefc..020ad943 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -5979,9 +5979,9 @@ infd_directory_handle_subscribe_session(InfdDirectory* directory, /* Only if we have already a proxy we could not have a request here */ g_assert(request != NULL); inf_request_fail(INF_REQUEST(request), local_error); - g_error_free(local_error); g_object_unref(request); g_free(seq); + g_propagate_error(error, local_error); return FALSE; } } From 4dfaf22925dbe12008627d0a604b179fd6e4b7b4 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Wed, 27 May 2015 22:21:22 -0400 Subject: [PATCH 52/60] Fix g_free / g_slice_free mismatch --- libinfinity/server/infd-directory.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index 020ad943..21d77cae 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -2701,6 +2701,7 @@ infd_directory_lookup_account(InfdDirectory* directory, InfdDirectoryPrivate* priv; InfdDirectoryTransientAccount* transient; InfAclAccount* result; + InfAclAccount* result_copy; guint i; priv = INFD_DIRECTORY_PRIVATE(directory); @@ -2735,8 +2736,21 @@ infd_directory_lookup_account(InfdDirectory* directory, return NULL; } - if(transient_index != NULL) *transient_index = priv->n_transient_accounts; - return result; + if(transient_index != NULL) + *transient_index = priv->n_transient_accounts; + + /* Note that the return value that we got from + * infd_account_storage_lookup_accounts() is actually an array, and + * therefore needs to be freed with inf_acl_account_array_free(). However, + * we only return a single account that we want to be freed with + * inf_acl_account_free(). Therefore, we are making a copy here -- note + * that the two free functions are in fact different if GSlice is enabled, + * since an array of InfAclAccounts in allocated with g_malloc, while a + * single InfAclAccount is allocated with GSlice. */ + result_copy = inf_acl_account_copy(result); + inf_acl_account_array_free(result, 1); + + return result_copy; } static InfAclAccountId From 28dd0736c7618861dd9a23e8793e4db865ce6a5e Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Sun, 7 Jun 2015 21:27:23 -0400 Subject: [PATCH 53/60] InfXmppConnection: Fix strncmp invocation when suggesting SASL mechanism --- libinfinity/common/inf-xmpp-connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libinfinity/common/inf-xmpp-connection.c b/libinfinity/common/inf-xmpp-connection.c index 45adc6f7..9ff262d3 100644 --- a/libinfinity/common/inf-xmpp-connection.c +++ b/libinfinity/common/inf-xmpp-connection.c @@ -2219,7 +2219,7 @@ inf_xmpp_connection_sasl_suggest_mechanism(InfXmppConnection* xmpp, } if(strncmp(iter, "ANONYMOUS", - MAX((size_t) (end - iter), sizeof("ANONYMOUS") - 1) == 0)) + MAX((size_t) (end - iter), sizeof("ANONYMOUS") - 1)) == 0) { suggestion = "ANONYMOUS"; break; From 4fc1227317eea35b87e10686daf467642c9abe1e Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 9 Jun 2015 21:20:23 -0400 Subject: [PATCH 54/60] Fix uninitialized variable when suggesting a SASL mechanism --- libinfinity/common/inf-xmpp-connection.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libinfinity/common/inf-xmpp-connection.c b/libinfinity/common/inf-xmpp-connection.c index 9ff262d3..9c66481c 100644 --- a/libinfinity/common/inf-xmpp-connection.c +++ b/libinfinity/common/inf-xmpp-connection.c @@ -2203,6 +2203,7 @@ inf_xmpp_connection_sasl_suggest_mechanism(InfXmppConnection* xmpp, gboolean has_mechanism; priv = INF_XMPP_CONNECTION_PRIVATE(xmpp); + suggestion = NULL; if(priv->sasl_own_context != NULL) { From 3fb2be4fb355ed44541d6da486dc73c5dd739ca3 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 12 Oct 2015 19:51:40 -0400 Subject: [PATCH 55/60] Fix integrity check in inf_text_chunk_get_byte_index_utf8() --- libinftext/inf-text-chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libinftext/inf-text-chunk.c b/libinftext/inf-text-chunk.c index 8164f815..6feb71ad 100644 --- a/libinftext/inf-text-chunk.c +++ b/libinftext/inf-text-chunk.c @@ -90,7 +90,7 @@ gsize inf_text_chunk_get_byte_index_utf8(InfTextChunk* self, guint offset) { #ifdef CHUNK_CHECK_INTEGRITY - g_assert(offset <= g_utf8_strlen(self, bytes)); + g_assert(offset <= g_utf8_strlen(text, bytes)); #endif return g_utf8_offset_to_pointer(text, offset) - text; From d447fc406c0ceb2766f69ffec28f017baa7ed7a9 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Mon, 12 Oct 2015 19:51:50 -0400 Subject: [PATCH 56/60] InfTextChunk: fix segment lookup for offset=0 (#10) This used to work with glib 2.42, but it seems that the semantics of g_sequence_search() have changed with respect to what item is returned when the comparison function returns 0. The behavior in that case is not documented. Fix this by passing a different comparison function that never returns 0, so that there is no ambiguity in which segment is returned. --- libinftext/inf-text-chunk.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/libinftext/inf-text-chunk.c b/libinftext/inf-text-chunk.c index 6feb71ad..96e3d6e8 100644 --- a/libinftext/inf-text-chunk.c +++ b/libinftext/inf-text-chunk.c @@ -181,6 +181,33 @@ inf_text_chunk_segment_cmp(gconstpointer first, return 1; } +/* This is a special comparison function which is only used + * in inf_text_chunk_get_segment. It makes sure that when two segments + * have the same offset, the second one gets sorted behind. This ensures + * that the first segment in the sequence is never returned, since it + * always has offset 0, which is a precondition for the algorithm + * in inf_text_chunk_get_segment. See also libinfinity github issue #10. */ +static int +inf_text_chunk_segment_cmp_for_get_segment(gconstpointer first, + gconstpointer second, + gpointer userdata) +{ + const InfTextChunkSegment* first_segment; + const InfTextChunkSegment* second_segment; + + first_segment = (const InfTextChunkSegment*)first; + second_segment = (const InfTextChunkSegment*)second; + + g_return_val_if_fail(second != NULL && first != NULL, 0); + + if (first_segment->offset < second_segment->offset) + return -1; + else if (first_segment->offset == second_segment->offset) + return -1; + else + return 1; +} + static guint inf_text_chunk_next_offset(InfTextChunk* self, GSequenceIter* iter) @@ -247,7 +274,7 @@ inf_text_chunk_get_segment(InfTextChunk* self, iter = g_sequence_search( self->segments, &key, - inf_text_chunk_segment_cmp, + inf_text_chunk_segment_cmp_for_get_segment, NULL ); From a7bdd262474898d180285129f5aed3e87b04461a Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 13 Oct 2015 19:34:35 -0400 Subject: [PATCH 57/60] Release libinfinity 0.6.7 --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 8727ded3..44a46f51 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +libinfinity 0.6.7: + * Fix a possible crash when an entry is removed from the document + browser. + * Fix a possible crash in infinoted when access control lists are + enabled. + * Fix an assertion failure when operating with text documents and + using glib 2.46 or newer. + libinfinity 0.6.6: * Fix certificates being only verified for expiration and other criteria such as weak algorithms if the CA is not trusted. From 2c047741eb8c91bde6be0af6329122d687237b82 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 13 Oct 2015 19:47:14 -0400 Subject: [PATCH 58/60] Post-release bump to 0.6.8 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d924945b..55ad6200 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -m4_define([libinfinity_version], [0.6.7]) +m4_define([libinfinity_version], [0.6.8]) m4_define([libinfinity_api_version], [0.6]) m4_define([libinfinity_libtool_version], [0:0:0]) From e59c1a4060f81fe989f9e291bcfa9721438328a4 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Tue, 8 Dec 2015 22:24:53 -0800 Subject: [PATCH 59/60] Fix g_return_val_if_fail on uninitialized memory --- libinfinity/server/infd-directory.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libinfinity/server/infd-directory.c b/libinfinity/server/infd-directory.c index 21d77cae..651d5119 100644 --- a/libinfinity/server/infd-directory.c +++ b/libinfinity/server/infd-directory.c @@ -11491,7 +11491,6 @@ infd_directory_create_acl_account(InfdDirectory* directory, InfAclAccountId account_id; g_return_val_if_fail(INFD_IS_DIRECTORY(directory), 0); - g_return_val_if_fail(account_id != 0, 0); g_return_val_if_fail(account_name != NULL, 0); g_return_val_if_fail(certificates != NULL || n_certificates == 0, 0); From 65b191b99814a1a0d4567261fd6a9f1d0f2f71b3 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 18 Mar 2016 18:56:23 +0100 Subject: [PATCH 60/60] Run apt-get noninteractive in travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c46008ce..252c6309 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ compiler: - gcc - clang before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq gtk-doc-tools libgnutls-dev libgsasl7-dev libxml2-dev libgtk-3-dev libavahi-client-dev libdaemon-dev libpam-dev + - sudo DEBIAN_FRONTEND=noninteractive apt-get update -qq + - sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq gtk-doc-tools libgnutls-dev libgsasl7-dev libxml2-dev libgtk-3-dev libavahi-client-dev libdaemon-dev libpam-dev script: ./autogen.sh --with-gtk3 --with-infgtk --with-inftextgtk --with-avahi --with-libdaemon --enable-gtk-doc && make && make check