GNOME Bugzilla – Bug 775685
gcr: Fix failure case in gcr_secure_memory_try_realloc()
Last modified: 2019-02-22 11:59:04 UTC
One important patch, and two tiny little compiler warning fixes. The important patch fixes the behaviour of gcr_secure_memory_try_*() to actually return NULL when allocation fails (for example, due to hitting RLIMIT_MEMLOCK), rather than hitting an assertion failure. Since RLIMIT_MEMLOCK can often be surprisingly low (for example, 64KiB), this can be hit fairly easily in an application which is trying to use secure memory for more than just key storage.
Created attachment 341449 [details] [review] gcr: Fix failure case in gcr_secure_memory_try_realloc() try_realloc() is explicitly documented as returning NULL in the failure case, so remove an assertion that it can never happen. Similarly for try_alloc(). This case can be hit if an application tries to allocate more than the process’ RLIMIT_MEMLOCK limit (and the process is not privileged). This limit is typically 64KiB, so not astronomical. Add a test case.
Created attachment 341450 [details] [review] gck: Remove an unnecessary (transfer) annotation GTypes cannot be owned or unowned, so a (transfer) annotation makes no sense. g-ir-scanner was warning about it.
Created attachment 341451 [details] [review] tests: Add missing const qualifier This fixes a compiler warning.
Thanks! Merged into gcr git master. Attachment 341449 [details] pushed as 9d66118 - gcr: Fix failure case in gcr_secure_memory_try_realloc() Attachment 341450 [details] pushed as 1ed6e17 - gck: Remove an unnecessary (transfer) annotation Attachment 341451 [details] pushed as d3935af - tests: Add missing const qualifier