Make sure the otr_dir is always slash-terminated 0.9.4
authorMikael Berthe <mikael@lilotux.net>
Sat, 27 Oct 2007 13:01:03 +0200
changeset 1335 ab1b7f7a682e
parent 1334 f8cfa22cedc2
child 1336 8ace83796feb
Make sure the otr_dir is always slash-terminated
mcabber/src/otr.c
--- 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)