Ø I have no idea wtf is up with all these bugs but i'm surprised openssl is this glitchy
It is not. The problem is almost definitely in your code. It is also hard to help when the code you post isn't the code you're trying to debug. Get and run valgrind and see what it says. Compile with many -W flags. /r$ -- Principal Security Engineer Akamai Technology Cambridge, MA