Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remove associated OTR keys when account is removed #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vqhuy
Copy link
Collaborator

@vqhuy vqhuy commented Oct 7, 2017

We need to use memcpy instead of assigning the pointer directly https://github.com/arlolra/ctypes-otr/pull/95/files#diff-0ae302860237c1727af8cba50ff6e1c6R272. Currently the app crashes because of "double free" (perhaps).

@vqhuy vqhuy changed the title Remove associated OTR keys when account is removed [WIP] Remove associated OTR keys when account is removed Oct 7, 2017
@vqhuy vqhuy force-pushed the tic23675 branch 3 times, most recently from 6f06513 to 5e5638f Compare October 8, 2017 16:11
let newKey = new libOTR.s_pending_privkey_calc();
newKey.accountname = libC.strdup(key.contents.accountname);
newKey.protocol = libC.strdup(key.contents.protocol);
newKey.privkey = key.contents.privkey;
Copy link
Collaborator Author

@vqhuy vqhuy Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have trouble with this, would love to hear your ideas here. @arlolra

I tried with length = gcry_sexp_sprint(); gcry_sexp_new(newKey.privkey, key.contents.privkey, length, {0,1}) but it didn't work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with length = gcry_sexp_sprint();

I'm assuming you mean gcry_sexp_length?

gcry_sexp_new(newKey.privkey, key.contents.privkey, length, {0,1}) but it didn't work.

The definition of gcry_sexp_new is such that the second argument is expected to be "its external representation" but here key.contents.privkey has already been parsed.

I would say to get it working with a memcpy for now.

Copy link
Collaborator Author

@vqhuy vqhuy Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you mean gcry_sexp_length?

Sorry, I should write it clearly. I meant length = gcry_sexp_sprint(privkey, {0,1,2,3}, null, 0). gcry_sexp_length doesn't seem to work here (gcry_sexp_length(key.contents.privkey) always returns 2).

@arlolra
Copy link
Owner

arlolra commented Oct 9, 2017

Currently the app crashes because of "double free" (perhaps).

Yeah, the calls to otrl_privkey_read_FILEp and then otrl_privkey_generate_cancelled in otrl_privkey_generate_finish_FILEp look like a double free.

@vqhuy
Copy link
Collaborator Author

vqhuy commented Oct 16, 2017

I think it works now. Tested with a Linux build applied TheTorProject/tor-messenger-build#15.
PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants