summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorz3bra <contactatz3bradotorg>2016-10-31 23:59:08 +0100
committerz3bra <contactatz3bradotorg>2016-11-08 16:47:51 +0100
commit92a1fc5853d2c78400ccb02c6c09bc42f6732a04 (patch)
treee36a195f3232d6e616ed2c9411c8887be0e7c054
parent4c121a138ebe4ac6283994bf9744f757c92e16d0 (diff)
Load data into Tox_Option structure
-rw-r--r--ratox.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ratox.c b/ratox.c
index fbeae7b..8c28831 100644
--- a/ratox.c
+++ b/ratox.c
@@ -1006,6 +1006,8 @@ dataload(void)
fd = open(savefile, O_RDONLY);
if (fd < 0) {
+ toxopt.savedata_length = 0;
+ toxopt.savedata_data = NULL;
if (encryptsavefile) {
reprompt1:
while (readpass("Data : New passphrase > ", &passphrase, &pplen) < 0);
@@ -1035,13 +1037,18 @@ reprompt1:
if (read(fd, data, sz) != sz)
eprintf("read %s:", savefile);
- if (tox_is_save_encrypted(data)) {
+ toxopt.savedata_length = sz;
+ toxopt.savedata_data = malloc(sz);
+ if (toxopt.savedata_data)
+ eprintf("malloc:");
+
+ if (tox_is_data_encrypted(data)) {
if (!encryptsavefile)
logmsg("Data : %s > Encrypted, but saving unencrypted\n", savefile);
while (readpass("Data : Passphrase > ", &passphrase, &pplen) < 0 ||
- tox_encrypted_load(tox, data, sz, passphrase, pplen) < 0);
+ !tox_pass_decrypt(data, sz, passphrase, pplen, toxopt.savedata_data));
} else {
- if (tox_load(tox, data, sz) < 0)
+ if (memcpy(toxopt.savedata_data, data, sz) < sz)
eprintf("Data : %s > Failed to load\n", savefile);
if (encryptsavefile) {
logmsg("Data : %s > Not encrypted, but saving encrypted\n", savefile);