summaryrefslogtreecommitdiff
path: root/libtrivfs
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-06-20 14:27:59 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-08-31 19:06:56 +0200
commit5f1011ac0ad676d1e7eaba14d1384180e98fb93e (patch)
tree4c4b37623d138c593d4d9220e4444d39fde2abd9 /libtrivfs
parent334801c52c9844c06eacbe2e3af65852f7412e3c (diff)
include: detect use-after-free errors using the reference counts
* include/refcount.h (refcount_init): There must be at least one reference at initialization time. (refcounts_init): Likewise. (refcount_unsafe_ref): New function retaining the previous functionality of refcount_ref. It is occasionally useful to raise the reference count again after it dropped to zero. (refcounts_unsafe_ref): Likewise. (refcounts_unsafe_weak_ref): Likewise. (refcount_ref): Detect use-after-free errors. (refcounts_ref): Likewise. (refcounts_ref_weak): Likewise. * libtrivfs/protid-clean.c (trivfs_clean_protid): Use refcount_unsafe_ref.
Diffstat (limited to 'libtrivfs')
-rw-r--r--libtrivfs/protid-clean.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c
index adc5e981..ff6cc167 100644
--- a/libtrivfs/protid-clean.c
+++ b/libtrivfs/protid-clean.c
@@ -36,7 +36,7 @@ trivfs_clean_protid (void *arg)
if (refcount_deref (&cred->po->refcnt) == 0)
{
/* Reacquire a reference while we call the hook. */
- refcount_ref (&cred->po->refcnt);
+ refcount_unsafe_ref (&cred->po->refcnt);
(*trivfs_peropen_destroy_hook) (cred->po);
if (refcount_deref (&cred->po->refcnt) == 0)
{