#include "utils.h"
#include "gtkutils.h"
#include "passcrypt.h"
-#include "base64.h"
#include "codeconv.h"
#define CL(x) (((gulong) (x) >> (gulong) 8) & 0xFFUL)
case P_PASSWORD:
g_free(*((gchar **)param[i].data));
if (value[0] == '!') {
- gchar tmp[1024];
- gint len;
+ gchar *tmp;
+ gsize len;
- len = base64_decode(tmp, &value[1], strlen(value) - 1);
+ tmp = g_base64_decode_zero(&value[1], &len);
passcrypt_decrypt(tmp, len);
- tmp[len] = '\0';
+
*((gchar **)param[i].data) =
*tmp ? g_strdup(tmp) : NULL;
+ g_free(tmp);
} else {
*((gchar **)param[i].data) =
*value ? g_strdup(value) : NULL;
break;
case P_PASSWORD:
{
- gchar *tmp = NULL, tmp2[1024] = {0};
+ gchar *tmp = NULL, *tmp2 = NULL;
tmp = *((gchar **)param[i].data);
if (tmp) {
tmp = g_strdup(tmp);
len = strlen(tmp);
passcrypt_encrypt(tmp, len);
- base64_encode(tmp2, tmp, len);
+ tmp2 = g_base64_encode(tmp, len);
g_free(tmp);
tmp = tmp2;
}
g_snprintf(buf, sizeof(buf), "%s=!%s\n", param[i].name,
tmp ?
tmp : "");
+ g_free(tmp);
}
break;
default:
g_strconcat(get_home_dir(),
param[i].defval + 1,
NULL);
- else if (param[i].defval[0] != '\0')
+ else
*((gchar **)param[i].data) =
g_strdup(param[i].defval);
- else
- *((gchar **)param[i].data) = NULL;
} else
*((gchar **)param[i].data) = NULL;
break;