From: Martin Storsjo Date: Wed, 31 Oct 2012 13:44:35 +0000 (+0200) Subject: server_name: Return the actual required buffer size if the buffer is too small X-Git-Tag: gnutls_3_1_4~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4b6bd3f3e61ff8af04f4d088718a8873512ca01;p=thirdparty%2Fgnutls.git server_name: Return the actual required buffer size if the buffer is too small Since we require space for the null termination, include this in the info returned if the caller provided a too small buffer. Otherwise, if the caller allocated a buffer of exactly the suggested size, it would still be too small. Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/ext/server_name.c b/lib/ext/server_name.c index 005d80b948..520b69f520 100644 --- a/lib/ext/server_name.c +++ b/lib/ext/server_name.c @@ -322,7 +322,7 @@ gnutls_server_name_get (gnutls_session_t session, void *data, } else { - *data_length = priv->server_names[indx].name_length; + *data_length = priv->server_names[indx].name_length + 1; return GNUTLS_E_SHORT_MEMORY_BUFFER; }