]> git.meshlink.io Git - meshlink/blobdiff - src/conf.c
Various fixes for the encrypted storage support.
[meshlink] / src / conf.c
index 9664e2b776a923a9d33d69451d5867c52986b5b4..1a3c82ae2e8c45e5cf07cceaf2945bcc9eaac6bf 100644 (file)
@@ -223,6 +223,7 @@ bool config_read_file(meshlink_handle_t *mesh, FILE *f, config_t *config) {
                chacha_poly1305_set_key(ctx, mesh->config_key);
 
                if(len > 12 && chacha_poly1305_decrypt_iv96(ctx, buf, buf + 12, len - 12, decrypted, &decrypted_len)) {
+                       chacha_poly1305_exit(ctx);
                        free(buf);
                        config->buf = decrypted;
                        config->len = decrypted_len;
@@ -230,6 +231,7 @@ bool config_read_file(meshlink_handle_t *mesh, FILE *f, config_t *config) {
                } else {
                        logger(mesh, MESHLINK_ERROR, "Cannot decrypt config file\n");
                        meshlink_errno = MESHLINK_ESTORAGE;
+                       chacha_poly1305_exit(ctx);
                        free(decrypted);
                        free(buf);
                        return false;
@@ -330,7 +332,7 @@ void config_scan_all(meshlink_handle_t *mesh, config_scan_action_t action) {
        DIR *dir;
        struct dirent *ent;
        char dname[PATH_MAX];
-       make_host_path(mesh, NULL, dname, sizeof(dname));
+       make_host_path(mesh, "", dname, sizeof(dname));
 
        dir = opendir(dname);