OpenSSL: don't erroneously truncate X509_NAMEs.
OpenSSL: don't erroneously truncate X509_NAMEs.

The manpage for X509_NAME_get_text_by_NID() says:

  At most len bytes will be written and the text written to buf will be
  null terminated.

And:

  If buf is <NULL> then the amount of space needed in buf (excluding the
  final null) is returned.

So we call X509_NAME_get_text_by_NID() once, passing a NULL buffer, to
discover how long a buffer we have to allocate. Then we allocate that
buffer, and pass it back in. But while the returned length excludes the
null terminator, the length we pass in should include it.

This fixes an issue where, when connecting to (for example) door.com,
we'd erroneously believe that its certificate is for "door.co" and
reject it.

Reviewed-by: Simon McVittie <2b470b34502dbf3ba4bcc04ea7e64f4e0e104f33@collabora.co.uk>

freedesktop-unofficial-mirror/wocky,freedesktop-unofficial-mirror/wocky,freedesktop-unofficial-mirror/wocky,noonien-d/wocky,noonien-d/wocky,noonien-d/wocky