[gnutls-devel] GnuTLS | Fix uninitialized warning in pkcs11.c (2063c619)
Development of GNU's TLS library
gnutls-devel at lists.gnutls.org
Wed Jan 30 14:27:13 CET 2019
Nikos Mavrogiannopoulos started a new discussion on lib/pkcs11.c:
>
> - if (temp_str)
> - len = strlen(temp_str);
> - else if (str_max == 0)
> - len = 0;
> - else
> - len = p11_kit_space_strlen(str, str_max);
> -
> - if (len + 1 > *output_size) {
> + if (len < *output_size) {
> + if (len)
> + memcpy(output, str, len);
> + ((char *) output)[len] = '\0';
> + *output_size = len;
> + ret = 0;
> + } else {
It looks good to me (the whole cleanup), but I'd feel safer if we added a test case to check for this particular error code before merging this clean this up. Seeing [the coverage of this file](https://gnutls.gitlab.io/coverage/master/builds/gnutls/coverage/gnutls-git/lib/pkcs11.c.gcov.html), it seems that the error case of `GNUTLS_E_SHORT_MEMORY_BUFFER` is not tested; and this function has no unit test (tested via p11tool's use only).
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/commit/2063c6193af6653175e6bc073babea607e5b0ff4#note_136560731
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20190130/8da59fd0/attachment.html>
More information about the Gnutls-devel
mailing list