2.1.22 is very old. See if it helps to upgrade.
OpenLDAP has had bugs with 8-bit characters, though admittedly I don't see how those would affect passwords.
Have you checked that the bug is not in your C program's input routine? Print out the password before passing it to OpenLDAP.