Closed bitblight closed 7 years ago
Yes, currently you must set homedir before calling netpgp_init. It's one of the various undocumented oddities of libnetpgp.
The way I was using it before switching to lower-level functions, was something like:
netpgp_set_homedir(&netpgp, "/home/username/", ".gnupg", 0);
netpgp_init(&netpgp);
Ah actually it crashes because netpgp_t currently needs to be zeroed prior to use, otherwise netpgp->c is not 0 and findvar will try to read garbage. At least that's my conclusion from a quick look.
Honestly I think the netpgp_* layers are a bit weird all around. The global variable store makes things difficult to debug sometimes (things like not setting "need seckey" at times can cause crashes too if I recall correctly).
@dewyatt Aha! Good catch! I'll add a memset() to netpgp_init.
edit: and if you happen to know of any other oddities like this please send me a list, it would be great to fix them early on.
I wrote a small test unit and found that libnetpgp causes an access violation when it attempts to read the "homedir" variable in netpgp_init:
Resulting in:
I suspect this is as a result of a null pointer finding its way to strcmp when an expected variable is not set. If it happens with "coredumps" it will likely happen with "homedir" as well.