summaryrefslogtreecommitdiff
path: root/lib/minitasn1/gstr.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/minitasn1/gstr.h')
-rw-r--r--lib/minitasn1/gstr.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/minitasn1/gstr.h b/lib/minitasn1/gstr.h
index 51db059489..00c335ca93 100644
--- a/lib/minitasn1/gstr.h
+++ b/lib/minitasn1/gstr.h
@@ -25,3 +25,18 @@ void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
+
+inline static
+void safe_memset(void *data, int c, size_t size)
+{
+ volatile unsigned volatile_zero = 0;
+ volatile char *vdata = (volatile char*)data;
+
+ /* This is based on a nice trick for safe memset,
+ * sent by David Jacobson in the openssl-dev mailing list.
+ */
+
+ if (size > 0) do {
+ memset(data, c, size);
+ } while(vdata[volatile_zero] != c);
+}