summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McManus <mcmanus@ducksong.com>2016-03-15 17:44:17 -0400
committerPatrick McManus <mcmanus@ducksong.com>2016-03-15 17:44:17 -0400
commit6f39485bd33920029a05c6760d28e0242943e4fd (patch)
tree2f200ed7425cee346f43f7b199146da91b11041d
parent7d329538edc95b70d3370ff1eb92dc071e1c7c38 (diff)
downloadnspr-hg-6f39485bd33920029a05c6760d28e0242943e4fd.tar.gz
Bug 1257250 - pr_getnameforidentity bounds check and locking r=ted.mielczarek
-rw-r--r--pr/src/io/prlayer.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pr/src/io/prlayer.c b/pr/src/io/prlayer.c
index faec9095..cadb7ca3 100644
--- a/pr/src/io/prlayer.c
+++ b/pr/src/io/prlayer.c
@@ -683,12 +683,17 @@ retry:
PR_IMPLEMENT(const char*) PR_GetNameForIdentity(PRDescIdentity ident)
{
+ const char *rv = NULL;
if (!_pr_initialized) _PR_ImplicitInitialization();
- if (PR_TOP_IO_LAYER == ident) return NULL;
+ if ((PR_TOP_IO_LAYER != ident) && (ident >= 0)) {
+ PR_Lock(identity_cache.ml);
+ PR_ASSERT(ident <= identity_cache.ident);
+ rv = (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
+ PR_Unlock(identity_cache.ml);
+ }
- PR_ASSERT(ident <= identity_cache.ident);
- return (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
+ return rv;
} /* PR_GetNameForIdentity */
PR_IMPLEMENT(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd)