summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2021-09-26 16:06:03 +0100
committerSimon McVittie <smcv@debian.org>2021-09-26 16:24:47 +0100
commitc2d8225130c9dac7d4deeaeb0c55c63e3dc811b7 (patch)
tree1ce2b6babbe143a487008097642cc82303051eb0
parentab88eeb947a6bb82875124e6fcaf67ece20ddd13 (diff)
downloadgnome-keyring-wip/smcv/allow-for-overhead.tar.gz
egg-secure-memory: Add a warning if gnome-keyring#36 happens againwip/smcv/allow-for-overhead
If we call sec_block_create() to allocate a block sized to hold `length` bytes, and we succeed, then we should really be able to sec_alloc() a cell of `length` bytes within that block. If we can't, then we chose the size of the block incorrectly. Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--egg/egg-secure-memory.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/egg/egg-secure-memory.c b/egg/egg-secure-memory.c
index 7391854d..0f6a3f62 100644
--- a/egg/egg-secure-memory.c
+++ b/egg/egg-secure-memory.c
@@ -1065,8 +1065,14 @@ egg_secure_alloc_full (const char *tag,
/* None of the current blocks have space, allocate new */
if (!memory) {
block = sec_block_create (length, tag);
- if (block)
+ if (block) {
memory = sec_alloc (block, tag, length);
+
+ if (!memory && egg_secure_warnings)
+ fprintf (stderr,
+ "internal error: memory block sized to hold %lu bytes was too small\n",
+ (unsigned long) length);
+ }
}
#ifdef WITH_VALGRIND