[gnome-keyring/wip/smcv/allow-for-overhead: 2/2] egg-secure-memory: Add a warning if gnome-keyring#36 happens again




commit c2d8225130c9dac7d4deeaeb0c55c63e3dc811b7
Author: Simon McVittie <smcv debian org>
Date:   Sun Sep 26 16:06:03 2021 +0100

    egg-secure-memory: Add a warning if gnome-keyring#36 happens again
    
    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>

 egg/egg-secure-memory.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]