diff options
author | Werner Koch <[email protected]> | 2021-06-14 17:51:28 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-06-14 17:51:28 +0000 |
commit | fde20940b5ca6986dc12215209e8858601bb0c2e (patch) | |
tree | c6f91404915bac0ccd6308fa8cce7c0c50bd68aa /src/cJSON.c | |
parent | core: Also detect AuthEnvelopedData (AEAD for CMS) (diff) | |
download | gpgme-fde20940b5ca6986dc12215209e8858601bb0c2e.tar.gz gpgme-fde20940b5ca6986dc12215209e8858601bb0c2e.zip |
core: New data flags "io-buffer-size" and "sensitive".
* src/data.c (_gpgme_data_release): Free buffers.
(gpgme_data_seek): Adjust from renamed fields.
(gpgme_data_set_flag): Implement new flags.
(_gpgme_data_inbound_handler): Allow the use of a malloced buffer.
(_gpgme_data_outbound_handler): Ditto.
* src/data.h (BUFFER_SIZE): Move out of the struct definition.
(struct gpgme_data): Remove pending filed and introduce inbound and
outbound fields.
* src/conversion.c (_gpgme_wipememory): New. Taken from GnuPG.
* src/cJSON.c (wipememory): Use this here too.
* tests/run-decrypt.c (main): Add options "--large-buffers" and
"--sensitive".
--
GnuPG-bug-id: 5478
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/cJSON.c')
-rw-r--r-- | src/cJSON.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/cJSON.c b/src/cJSON.c index 7769b0eb..1925a04e 100644 --- a/src/cJSON.c +++ b/src/cJSON.c @@ -50,21 +50,13 @@ #include "cJSON.h" + /* Only use calloc. */ #define CALLOC_ONLY 1 /* Maximum recursion depth */ #define MAX_DEPTH 512 -/* To avoid that a compiler optimizes certain memset calls away, these - macros may be used instead. */ -#define wipememory2(_ptr,_set,_len) do { \ - volatile char *_vptr=(volatile char *)(_ptr); \ - size_t _vlen=(_len); \ - while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ - } while(0) -#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) - /* We use malloc function wrappers from gpgrt (aka libgpg-error). */ #include <gpgrt.h> #define xtrycalloc(a,b) gpgrt_calloc ((a), (b)) @@ -77,6 +69,16 @@ #endif +static void +wipememory (void *ptr, size_t len) +{ + /* Prevent compiler from optimizing away the call to memset by accessing + * memset through volatile pointer. */ + static void *(*volatile memset_ptr)(void *, int, size_t) = (void *)memset; + memset_ptr (ptr, 0, len); +} + + static int cJSON_strcasecmp (const char *s1, const char *s2) { |