From: Nikos Mavrogiannopoulos Date: Fri, 18 Apr 2014 21:11:25 +0000 (+0200) Subject: copy_string() and copy_data() are more resilient on null input X-Git-Tag: gnutls_3_3_1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa8f6f63da598c16a144f9aceee6d904e3207f3a;p=thirdparty%2Fgnutls.git copy_string() and copy_data() are more resilient on null input --- diff --git a/lib/x509/common.c b/lib/x509/common.c index 5f63dcf615..77a90a7336 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -1863,9 +1863,11 @@ unsigned size_to_check; return GNUTLS_E_SHORT_MEMORY_BUFFER; } - if (out != NULL) { + if (out != NULL && str->data != NULL) { memcpy(out, str->data, str->size); out[str->size] = 0; + } else if (out != NULL) { + out[0] = 0; } *out_size = str->size; @@ -1880,7 +1882,7 @@ int _gnutls_copy_data(gnutls_datum_t* str, uint8_t *out, size_t *out_size) return GNUTLS_E_SHORT_MEMORY_BUFFER; } - if (out != NULL) { + if (out != NULL && str->data != NULL) { memcpy(out, str->data, str->size); } *out_size = str->size;