summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-31 10:20:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-03-31 13:38:01 +0100
commit026b17b7d725109f586622755b435ded3673c43a (patch)
tree685262a3a279833535f2b53584e311ce290aef83 /sal
parent01b615687fe0f39c65e0e8290db434db2f1ef8ac (diff)
V597: introduce a rtl_secureZeroMemory
Change-Id: Id28046eb318cd3b2ed0b813fd266617547cf6ee2
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/alloc_cache.cxx15
-rw-r--r--sal/rtl/alloc_global.cxx2
-rw-r--r--sal/rtl/digest.cxx4
-rw-r--r--sal/util/sal.map5
4 files changed, 23 insertions, 3 deletions
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index 5944043eebb3..578ce33f19ac 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -1314,6 +1314,15 @@ rtl_cache_wsupdate_fini();
#if defined(SAL_UNX)
+void SAL_CALL
+rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
+{
+ //currently glibc doesn't implement memset_s
+ volatile char *p = reinterpret_cast<volatile char*>(Ptr);
+ while (Bytes--)
+ *p++ = 0;
+}
+
#include <sys/time.h>
static void *
@@ -1369,6 +1378,12 @@ rtl_cache_wsupdate_fini()
#elif defined(SAL_W32)
+void SAL_CALL
+rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
+{
+ RtlSecureZeroMemory(Ptr, Bytes);
+}
+
static DWORD WINAPI
rtl_cache_wsupdate_all (void * arg);
diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx
index 69313708e3e5..60dbc9c85b78 100644
--- a/sal/rtl/alloc_global.cxx
+++ b/sal/rtl/alloc_global.cxx
@@ -374,7 +374,7 @@ void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
{
if (p != 0)
{
- memset (p, 0, n);
+ rtl_secureZeroMemory (p, n);
rtl_freeMemory (p);
}
}
diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx
index 5aba0ea91b67..d8f4c7119142 100644
--- a/sal/rtl/digest.cxx
+++ b/sal/rtl/digest.cxx
@@ -2071,7 +2071,7 @@ static void __rtl_digest_updatePBKDF2 (
for (k = 0; k < DIGEST_CBLOCK_PBKDF2; k++) T[k] ^= U[k];
}
- memset (U, 0, DIGEST_CBLOCK_PBKDF2);
+ rtl_secureZeroMemory (U, DIGEST_CBLOCK_PBKDF2);
}
/*========================================================================
@@ -2124,7 +2124,7 @@ rtlDigestError SAL_CALL rtl_digest_PBKDF2 (
/* DK ||= T_(i) */
memcpy (pKeyData, T, nKeyLen);
- memset (T, 0, DIGEST_CBLOCK_PBKDF2);
+ rtl_secureZeroMemory (T, DIGEST_CBLOCK_PBKDF2);
}
memset (&digest, 0, sizeof (digest));
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 6acd9c44470e..2a87243e4813 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -678,6 +678,11 @@ LIBO_UDK_4.3 { # symbols available in >= LibO 4.3
osl_areCommandArgsSet;
} LIBO_UDK_4.2;
+LIBO_UDK_4.5 { # symbols available in >= LibO 4.5
+ global:
+ rtl_secureZeroMemory;
+} LIBO_UDK_4.3;
+
PRIVATE_1.0 {
global:
osl_detail_ObjectRegistry_storeAddresses;