changeset 1335:ab1b7f7a682e 0.9.4

Make sure the otr_dir is always slash-terminated
author Mikael Berthe <mikael@lilotux.net>
date Sat, 27 Oct 2007 13:01:03 +0200
parents f8cfa22cedc2
children 8ace83796feb
files mcabber/src/otr.c
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/otr.c	Sat Oct 27 12:01:55 2007 +0200
+++ b/mcabber/src/otr.c	Sat Oct 27 13:01:03 2007 +0200
@@ -163,10 +163,21 @@
 {
   char * configured_dir = (char *)settings_opt_get("otr_dir");
 
-  if (configured_dir)
-    return expand_filename(configured_dir);
-  else
+  if (configured_dir && *configured_dir) {
+    char *xp_conf_dir;
+    int l;
+    xp_conf_dir = expand_filename(configured_dir);
+    // The path must be slash-terminated
+    l = strlen(xp_conf_dir);
+    if (xp_conf_dir[l-1] != '/') {
+      char *xp_conf_dir_tmp = xp_conf_dir;
+      xp_conf_dir = g_strdup_printf("%s/", xp_conf_dir_tmp);
+      g_free(xp_conf_dir_tmp);
+    }
+    return xp_conf_dir;
+  } else {
     return expand_filename("~/.mcabber/otr/");
+  }
 }
 
 static ConnContext * otr_get_context(const char *buddy)