change sqlcipher memory functions to use u64 params
This commit is contained in:
parent
621d7044f3
commit
005ea9d083
|
@ -240,13 +240,13 @@ void sqlcipher_deactivate() {
|
||||||
optimized out by the compiler.
|
optimized out by the compiler.
|
||||||
Note: As suggested by Joachim Schipper (joachim.schipper@fox-it.com)
|
Note: As suggested by Joachim Schipper (joachim.schipper@fox-it.com)
|
||||||
*/
|
*/
|
||||||
void* sqlcipher_memset(void *v, unsigned char value, int len) {
|
void* sqlcipher_memset(void *v, unsigned char value, u64 len) {
|
||||||
int i = 0;
|
u64 i = 0;
|
||||||
volatile unsigned char *a = v;
|
volatile unsigned char *a = v;
|
||||||
|
|
||||||
if (v == NULL) return v;
|
if (v == NULL) return v;
|
||||||
|
|
||||||
CODEC_TRACE_MEMORY("sqlcipher_memset: setting %p[0-%d]=%d)\n", a, len, value);
|
CODEC_TRACE_MEMORY("sqlcipher_memset: setting %p[0-%llu]=%d)\n", a, len, value);
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
a[i] = value;
|
a[i] = value;
|
||||||
}
|
}
|
||||||
|
@ -257,9 +257,9 @@ void* sqlcipher_memset(void *v, unsigned char value, int len) {
|
||||||
/* constant time memory check tests every position of a memory segement
|
/* constant time memory check tests every position of a memory segement
|
||||||
matches a single value (i.e. the memory is all zeros)
|
matches a single value (i.e. the memory is all zeros)
|
||||||
returns 0 if match, 1 of no match */
|
returns 0 if match, 1 of no match */
|
||||||
int sqlcipher_ismemset(const void *v, unsigned char value, int len) {
|
int sqlcipher_ismemset(const void *v, unsigned char value, u64 len) {
|
||||||
const unsigned char *a = v;
|
const unsigned char *a = v;
|
||||||
int i = 0, result = 0;
|
u64 i = 0, result = 0;
|
||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
result |= a[i] ^ value;
|
result |= a[i] ^ value;
|
||||||
|
@ -281,7 +281,7 @@ int sqlcipher_memcmp(const void *v0, const void *v1, int len) {
|
||||||
return (result != 0);
|
return (result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sqlcipher_mlock(void *ptr, int sz) {
|
void sqlcipher_mlock(void *ptr, u64 sz) {
|
||||||
#ifndef OMIT_MEMLOCK
|
#ifndef OMIT_MEMLOCK
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -308,7 +308,7 @@ void sqlcipher_mlock(void *ptr, int sz) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sqlcipher_munlock(void *ptr, int sz) {
|
void sqlcipher_munlock(void *ptr, u64 sz) {
|
||||||
#ifndef OMIT_MEMLOCK
|
#ifndef OMIT_MEMLOCK
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -343,8 +343,8 @@ void sqlcipher_munlock(void *ptr, int sz) {
|
||||||
* If sz is > 0, and not compiled with OMIT_MEMLOCK, system will attempt to unlock the
|
* If sz is > 0, and not compiled with OMIT_MEMLOCK, system will attempt to unlock the
|
||||||
* memory segment so it can be paged
|
* memory segment so it can be paged
|
||||||
*/
|
*/
|
||||||
void sqlcipher_free(void *ptr, int sz) {
|
void sqlcipher_free(void *ptr, u64 sz) {
|
||||||
CODEC_TRACE_MEMORY("sqlcipher_free: calling sqlcipher_memset(%p,0,%d)\n", ptr, sz);
|
CODEC_TRACE_MEMORY("sqlcipher_free: calling sqlcipher_memset(%p,0,%llu)\n", ptr, sz);
|
||||||
sqlcipher_memset(ptr, 0, sz);
|
sqlcipher_memset(ptr, 0, sz);
|
||||||
sqlcipher_munlock(ptr, sz);
|
sqlcipher_munlock(ptr, sz);
|
||||||
sqlite3_free(ptr);
|
sqlite3_free(ptr);
|
||||||
|
@ -355,11 +355,11 @@ void sqlcipher_free(void *ptr, int sz) {
|
||||||
* reference counted and leak detection works. Unless compiled with OMIT_MEMLOCK
|
* reference counted and leak detection works. Unless compiled with OMIT_MEMLOCK
|
||||||
* attempts to lock the memory pages so sensitive information won't be swapped
|
* attempts to lock the memory pages so sensitive information won't be swapped
|
||||||
*/
|
*/
|
||||||
void* sqlcipher_malloc(int sz) {
|
void* sqlcipher_malloc(u64 sz) {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
CODEC_TRACE_MEMORY("sqlcipher_malloc: calling sqlite3Malloc(%d)\n", sz);
|
CODEC_TRACE_MEMORY("sqlcipher_malloc: calling sqlite3Malloc(%llu)\n", sz);
|
||||||
ptr = sqlite3Malloc(sz);
|
ptr = sqlite3Malloc(sz);
|
||||||
CODEC_TRACE_MEMORY("sqlcipher_malloc: calling sqlcipher_memset(%p,0,%d)\n", ptr, sz);
|
CODEC_TRACE_MEMORY("sqlcipher_malloc: calling sqlcipher_memset(%p,0,%llu)\n", ptr, sz);
|
||||||
sqlcipher_memset(ptr, 0, sz);
|
sqlcipher_memset(ptr, 0, sz);
|
||||||
sqlcipher_mlock(ptr, sz);
|
sqlcipher_mlock(ptr, sz);
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
@ -72,14 +72,13 @@ typedef struct {
|
||||||
} sqlcipher_provider;
|
} sqlcipher_provider;
|
||||||
|
|
||||||
/* utility functions */
|
/* utility functions */
|
||||||
void sqlcipher_free(void *, int);
|
void* sqlcipher_malloc(u64);
|
||||||
void* sqlcipher_malloc(int);
|
void sqlcipher_mlock(void *, u64);
|
||||||
void sqlcipher_mlock(void *, int);
|
void sqlcipher_munlock(void *, u64);
|
||||||
void sqlcipher_munlock(void *, int);
|
void* sqlcipher_memset(void *, unsigned char, u64);
|
||||||
void* sqlcipher_memset(void *, unsigned char, int);
|
int sqlcipher_ismemset(const void *, unsigned char, u64);
|
||||||
int sqlcipher_ismemset(const void *, unsigned char, int);
|
|
||||||
int sqlcipher_memcmp(const void *, const void *, int);
|
int sqlcipher_memcmp(const void *, const void *, int);
|
||||||
void sqlcipher_free(void *, int);
|
void sqlcipher_free(void *, u64);
|
||||||
char* sqlcipher_version();
|
char* sqlcipher_version();
|
||||||
|
|
||||||
/* provider interfaces */
|
/* provider interfaces */
|
||||||
|
|
Loading…
Reference in New Issue