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

Bug#824872: jessie-pu: package nspr/2:4.12-2+deb8u1



Control: tag -1 -moreinfo

Hi Julien,
thanks a lot for following up on this!

On Fri, May 27, 2016 at 10:11:59PM +0200, Julien Cristau wrote:
> Control: tag -1 moreinfo
> 
> On Fri, May 20, 2016 at 18:32:41 +0200, Guido Günther wrote:
> > Hi,
> > as put out in more detail in
> > 
> >   https://lists.debian.org/debian-release/2016/02/msg00753.html
> > 
> > we discussed in the LTS and security team the possibility to use the
> > same NSS and NSPR upstream version in all suites to be able to handle
> > things like CVE-2014-3566 and CVE-2015-4000 in a consistent manner.
> > 
> > I'd like to propose this here again via a bug report so we have easier
> > means of tracking/tagging. Would it be o.k. with the release team to update
> > nss/nspr to the versions currently in sid/testing and continue to do so
> > from here on. If it works out for jessie we'll do the same in LTS via
> > wheezy-security.
> > In order to increase confidence in the backports I've enabled the
> > internal testsuites in nspr and nss.
> > 
> > If this is o.k. I'm happy to attach debdiffs and provide a matching bug
> > for nss as well.
> > 
> Hi Guido,
> 
> I'd want to see debdiffs first.  And have some description of what the
> regression testing looks like, both of the upstream releases and of the
> debian packages.

Diffs for nspr of the current backport to Jessie are attached. I've
diffed against the current sid versions as well as the current Jessie
version.

Upstream has an internal test suite which we enabled for the package
builds in nspr as well as nss (+ some autopkg smoke test in nss
itself). Howver I don't know as to what extend ABI compatibility is
tested upstream. Hopefully Mike (cc:) may have some input on this.

In order get some ideas about ABI compatibility myself I ran
abi-compliance-tester. The results for both NSS and NSPR are also
attached. We would do that on all point release updates.

Note that the only (as to my understanding) serious regression has been
pointed out by Florian as well:

    https://lists.debian.org/debian-lts/2015/11/msg00037.html
    https://bugzilla.redhat.com/show_bug.cgi?id=1260698

and it's unclear if this part of the ABI. The API break (removal of
CERT_FindCertURLExtension) is bogus since the symbol was not exported.

Cheers,
 -- Guido

[1] We could do this as autopkg test fetching the baseline version from
snapshot.d.o once we have coverage of p-u on ci.debian.net for that.
diff --git a/debian/changelog b/debian/changelog
index 30e0a9d..8bc4173 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,70 @@
-nspr (2:4.10.7-1+deb8u1) jessie-security; urgency=high
+nspr (2:4.12-2~bpo8) jessie-backports; urgency=medium
 
-  * Non-maintainer upload.
-  * Fix CVE-2015-7183, mfsa-2015-133: heap-buffer overflow in
-    PL_ARENA_ALLOCATE
+  * Backport to jessie and enable internal test suite
 
- -- Santiago Ruano Rincón <santiago@debian.org>  Mon, 16 Nov 2015 22:55:05 +0100
+ -- Guido Günther <agx@sigxcpu.org>  Fri, 20 May 2016 17:37:53 +0200
+
+nspr (2:4.12-2) unstable; urgency=medium
+
+  * debian/rules, debian/libnspr4.triggers. Replace makeshlibs scripts that
+    don't exist anymore with ldconfig triggers. Closes: #811118.
+
+ -- Mike Hommey <glandium@debian.org>  Sun, 03 Apr 2016 17:36:49 +0900
+
+nspr (2:4.12-1) unstable; urgency=medium
+
+  * New upstream release.
+  * debian/libnspr4.symbols: Updated.
+
+ -- Mike Hommey <glandium@debian.org>  Wed, 09 Mar 2016 09:28:19 +0900
+
+nspr (2:4.11-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Mike Hommey <glandium@debian.org>  Wed, 25 Nov 2015 09:02:00 +0900
+
+nspr (2:4.10.10-1) unstable; urgency=high
+
+  * New upstream release.
+  * Fixes mfsa-2015-133, aka CVE-2015-7183.
+
+ -- Mike Hommey <glandium@debian.org>  Wed, 04 Nov 2015 08:25:04 +0900
+
+nspr (2:4.10.9-2) unstable; urgency=medium
+
+  * nspr/pr/include/md/_linux.cfg: Fix mips64 condition testing, avoiding
+    e.g. wrong types being picked up on mips/mipsel.
+
+ -- Mike Hommey <glandium@debian.org>  Sat, 29 Aug 2015 10:22:50 +0900
+
+nspr (2:4.10.9-1) unstable; urgency=medium
+
+  * New upstream release.
+  * debian/libnspr4.symbols: Updated.
+
+ -- Mike Hommey <glandium@debian.org>  Sat, 22 Aug 2015 08:59:00 +0900
+
+nspr (2:4.10.8-2) unstable; urgency=medium
+
+  * debian/rules:
+    - Do not pretend nspr's configure can be run through dh_auto_configure.
+      The architecture flags are different than "standard" autoconf.
+      Closes: #782983.
+    - Use changelog date to feed nspr build system.
+    - Pass --enable-x32 for x32 builds.
+  * debian/libnspr4.symbols:
+    - Updated for x32-specific symbols. Thanks to Daniel Schepler
+      <dschepler@gmail.com>.
+    - Reordered symbols.
+
+ -- Mike Hommey <glandium@debian.org>  Thu, 28 May 2015 15:02:05 +0900
+
+nspr (2:4.10.8-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Mike Hommey <glandium@debian.org>  Wed, 01 Apr 2015 16:43:15 +0900
 
 nspr (2:4.10.7-1) unstable; urgency=medium
 
diff --git a/debian/libnspr4.symbols b/debian/libnspr4.symbols
index 499b175..841ab27 100644
--- a/debian/libnspr4.symbols
+++ b/debian/libnspr4.symbols
@@ -97,6 +97,7 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PR_DetachSharedMemory@Base 1.8.0.10
  PR_DetachThread@Base 1.8.0.10
  PR_DisableClockInterrupts@Base 1.8.0.10
+ PR_DuplicateEnvironment@Base 2:4.10.9 1
  PR_EmulateAcceptRead@Base 1.8.0.10
  PR_EmulateSendFile@Base 1.8.0.10
  PR_EnableClockInterrupts@Base 1.8.0.10
@@ -149,6 +150,7 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PR_GetDirectorySeparator@Base 1.8.0.10
  PR_GetDirectorySepartor@Base 1.8.0.10
  PR_GetEnv@Base 1.8.0.10
+ PR_GetEnvSecure@Base 2:4.12 1
  PR_GetError@Base 1.8.0.10
  PR_GetErrorText@Base 1.8.0.10
  PR_GetErrorTextLength@Base 1.8.0.10
@@ -314,6 +316,7 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PR_SetAlarm@Base 1.8.0.10
  PR_SetConcurrency@Base 1.8.0.10
  PR_SetCounter@Base 1.8.0.10
+ PR_SetCurrentThreadName@Base 2:4.9.2 1
  PR_SetEnv@Base 1.8.0.10
  PR_SetError@Base 1.8.0.10
  PR_SetErrorText@Base 1.8.0.10
@@ -330,7 +333,6 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PR_SetThreadAffinityMask@Base 1.8.0.10
  PR_SetThreadDumpProc@Base 1.8.0.10
  PR_SetThreadGCAble@Base 1.8.0.10
- PR_SetCurrentThreadName@Base 2:4.9.2 1
  PR_SetThreadPriority@Base 1.8.0.10
  PR_SetThreadPrivate@Base 1.8.0.10
  PR_SetThreadRecycleMode@Base 1.8.0.10
@@ -393,16 +395,6 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PR_vsxprintf@Base 1.8.0.10
  PT_FPrintStats@Base 1.8.0.10
  SetExecutionEnvironment@Base 1.8.0.10
- _pr_push_ipv6toipv4_layer@Base 1.8.0.10
- _pr_test_ipv6_socket@Base 1.8.0.10
- (arch=amd64 kfreebsd-amd64)_PR_x86_64_AtomicAdd@Base 1.8.0.10
- (arch=amd64 kfreebsd-amd64)_PR_x86_64_AtomicDecrement@Base 1.8.0.10
- (arch=amd64 kfreebsd-amd64)_PR_x86_64_AtomicIncrement@Base 1.8.0.10
- (arch=amd64 kfreebsd-amd64)_PR_x86_64_AtomicSet@Base 1.8.0.10
- (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicAdd@Base 1.8.0.10
- (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicDecrement@Base 1.8.0.10
- (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicIncrement@Base 1.8.0.10
- (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicSet@Base 1.8.0.10
  (arch=ia64)_PR_ia64_AtomicAdd@Base 1.8.0.10
  (arch=ia64)_PR_ia64_AtomicDecrement@Base 1.8.0.10
  (arch=ia64)_PR_ia64_AtomicIncrement@Base 1.8.0.10
@@ -411,6 +403,16 @@ libnspr4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  (arch=powerpc powerpcspe)_PR_ppc_AtomicDecrement@Base 4.7.0
  (arch=powerpc powerpcspe)_PR_ppc_AtomicIncrement@Base 4.7.0
  (arch=powerpc powerpcspe)_PR_ppc_AtomicSet@Base 4.7.0
+ (arch=amd64 kfreebsd-amd64 x32)_PR_x86_64_AtomicAdd@Base 1.8.0.10
+ (arch=amd64 kfreebsd-amd64 x32)_PR_x86_64_AtomicDecrement@Base 1.8.0.10
+ (arch=amd64 kfreebsd-amd64 x32)_PR_x86_64_AtomicIncrement@Base 1.8.0.10
+ (arch=amd64 kfreebsd-amd64 x32)_PR_x86_64_AtomicSet@Base 1.8.0.10
+ (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicAdd@Base 1.8.0.10
+ (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicDecrement@Base 1.8.0.10
+ (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicIncrement@Base 1.8.0.10
+ (arch=i386 kfreebsd-i386 hurd-i386)_PR_x86_AtomicSet@Base 1.8.0.10
+ _pr_push_ipv6toipv4_layer@Base 1.8.0.10
+ _pr_test_ipv6_socket@Base 1.8.0.10
  libVersionPoint@Base 1.8.0.10
 libplc4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PL_Base64Decode@Base 1.8.0.10
@@ -479,6 +481,6 @@ libplds4.so libnspr4 (>= 2:4.9-2~) | libnspr4-0d #MINVER#
  PL_HashTableRawRemove@Base 1.8.0.10
  PL_HashTableRemove@Base 1.8.0.10
  PL_InitArenaPool@Base 1.8.0.10
- PL_SizeOfArenaPoolExcludingPool@Base 2:4.9.6~ 1
  PL_NewHashTable@Base 1.8.0.10
+ PL_SizeOfArenaPoolExcludingPool@Base 2:4.9.6~ 1
  libVersionPoint@Base 1.8.0.10
diff --git a/debian/libnspr4.triggers b/debian/libnspr4.triggers
new file mode 100644
index 0000000..dd86603
--- /dev/null
+++ b/debian/libnspr4.triggers
@@ -0,0 +1 @@
+activate-noawait ldconfig
diff --git a/debian/patches/CVE-2015-7183-1.patch b/debian/patches/CVE-2015-7183-1.patch
deleted file mode 100644
index 15a3778..0000000
--- a/debian/patches/CVE-2015-7183-1.patch
+++ /dev/null
@@ -1,158 +0,0 @@
-
-# HG changeset patch
-# User Ryan Sleevi <ryan.sleevi@gmail.com>
-# Date 1444930561 -7200
-# Node ID c9c965b2b19cb7076dbadc19c9e68ec4a9cd4ea0
-# Parent  f40f22264704fdb13026a4ee17749b2d2cc71605
-Fix bug 1205157, r=wtc
-Origin, upstream: http://hg.mozilla.org/projects/nspr/rev/c9c965b2b19c
-Reviewed-by: Santiago R.R <santiagorr@riseup.net>
-
-diff --git a/nspr/lib/ds/plarena.c b/nspr/lib/ds/plarena.c
---- a/nspr/lib/ds/plarena.c
-+++ b/nspr/nspr/lib/ds/plarena.c
-@@ -88,16 +88,19 @@ PR_IMPLEMENT(void) PL_InitArenaPool(
-         align = PL_ARENA_DEFAULT_ALIGN;
- 
-     if (align < sizeof(pmasks)/sizeof(pmasks[0]))
-         pool->mask = pmasks[align];
-     else
-         pool->mask = PR_BITMASK(PR_CeilingLog2(align));
- 
-     pool->first.next = NULL;
-+    /* Set all three addresses in pool->first to the same dummy value.
-+     * These addresses are only compared with each other, but never
-+     * dereferenced. */
-     pool->first.base = pool->first.avail = pool->first.limit =
-         (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
-     pool->current = &pool->first;
-     /*
-      * Compute the net size so that each arena's gross size is |size|.
-      * sizeof(PLArena) + pool->mask is the header and alignment slop
-      * that PL_ArenaAllocate adds to the net size.
-      */
-@@ -139,20 +142,24 @@ PR_IMPLEMENT(void) PL_InitArenaPool(
- ** See also: bugzilla: 45343.
- **
- */
- 
- PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
- {
-     PLArena *a;   
-     char *rp;     /* returned pointer */
-+    PRUint32 nbOld;
- 
-     PR_ASSERT((nb & pool->mask) == 0);
-     
-+    nbOld = nb;
-     nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */
-+    if (nb < nbOld)
-+        return NULL;
- 
-     /* attempt to allocate from arenas at pool->current */
-     {
-         a = pool->current;
-         do {
-             if ( nb <= a->limit - a->avail )  {
-                 pool->current = a;
-                 rp = (char *)a->avail;
-@@ -203,16 +210,17 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PL
-             a = (PLArena*)PR_MALLOC(sz);
-         }
-         if ( NULL != a )  {
-             a->limit = (PRUword)a + sz;
-             a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
-             PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
-             rp = (char *)a->avail;
-             a->avail += nb;
-+            PR_ASSERT(a->avail <= a->limit);
-             /* the newly allocated arena is linked after pool->current 
-             *  and becomes pool->current */
-             a->next = pool->current->next;
-             pool->current->next = a;
-             pool->current = a;
-             if ( NULL == pool->first.next )
-                 pool->first.next = a;
-             PL_COUNT_ARENA(pool,++);
-@@ -225,16 +233,18 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PL
-     return(NULL);
- } /* --- end PL_ArenaAllocate() --- */
- 
- PR_IMPLEMENT(void *) PL_ArenaGrow(
-     PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr)
- {
-     void *newp;
- 
-+    if (PR_UINT32_MAX - size < incr)
-+        return NULL;
-     PL_ARENA_ALLOCATE(newp, pool, size + incr);
-     if (newp)
-         memcpy(newp, p, size);
-     return newp;
- }
- 
- static void ClearArenaList(PLArena *a, PRInt32 pattern)
- {
-diff --git a/nspr/lib/ds/plarena.h b/lib/ds/plarena.h
---- a/nspr/lib/ds/plarena.h
-+++ b/nspr/lib/ds/plarena.h
-@@ -134,42 +134,47 @@ void __asan_unpoison_memory_region(void 
- #define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)
- #endif
- 
- #define PL_ARENA_ALLOCATE(p, pool, nb) \
-     PR_BEGIN_MACRO \
-         PLArena *_a = (pool)->current; \
-         PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
-         PRUword _p = _a->avail; \
--        PRUword _q = _p + _nb; \
--        if (_q > _a->limit) { \
-+        if (_nb < nb) { \
-+            _p = 0; \
-+        } else if (_nb > (_a->limit - _a->avail)) { \
-             _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
-         } else { \
--            _a->avail = _q; \
-+            _a->avail += _nb; \
-         } \
-         p = (void *)_p; \
--        PL_MAKE_MEM_UNDEFINED(p, nb); \
--        PL_ArenaCountAllocation(pool, nb); \
-+        if (p) { \
-+            PL_MAKE_MEM_UNDEFINED(p, nb); \
-+            PL_ArenaCountAllocation(pool, nb); \
-+        } \
-     PR_END_MACRO
- 
- #define PL_ARENA_GROW(p, pool, size, incr) \
-     PR_BEGIN_MACRO \
-         PLArena *_a = (pool)->current; \
-         PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
--        PRUword _p = _a->avail; \
--        PRUword _q = _p + _incr; \
--        if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
--            _q <= _a->limit) { \
-+        if (_incr < incr) { \
-+            p = NULL; \
-+        } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
-+            _incr <= (_a->limit - _a->avail)) { \
-             PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, incr); \
--            _a->avail = _q; \
-+            _a->avail += _incr; \
-             PL_ArenaCountInplaceGrowth(pool, size, incr); \
-         } else { \
-             p = PL_ArenaGrow(pool, p, size, incr); \
-         } \
--        PL_ArenaCountGrowth(pool, size, incr); \
-+        if (p) {\
-+            PL_ArenaCountGrowth(pool, size, incr); \
-+        } \
-     PR_END_MACRO
- 
- #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
- #define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
- 
- #define PL_CLEAR_UNUSED_PATTERN(a, pattern) \
-     PR_BEGIN_MACRO \
-         PR_ASSERT((a)->avail <= (a)->limit); \
-
diff --git a/debian/patches/CVE-2015-7183-2.patch b/debian/patches/CVE-2015-7183-2.patch
deleted file mode 100644
index 17c43ee..0000000
--- a/debian/patches/CVE-2015-7183-2.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-
-# HG changeset patch
-# User Kai Engert <kaie@kuix.de>
-# Date 1444984353 -7200
-# Node ID bd8fb4498fa6ae6450ba9ea313c391ef8e30ccfe
-# Parent  854c880c68ad55fefb2382cdee8e8ea4acd15dcf
-Bug 1205157, add typecasts to handle signed integer parameters, r=ttaubert
-Origin: upstream, http://hg.mozilla.org/projects/nspr/rev/bd8fb4498fa6
-Reviewed-by: Santiago R.R. <santiagorr@riseup.net>
-
---- a/nspr/lib/ds/plarena.h
-+++ b/nspr/lib/ds/plarena.h
-@@ -137,9 +137,9 @@
- #define PL_ARENA_ALLOCATE(p, pool, nb) \
-     PR_BEGIN_MACRO \
-         PLArena *_a = (pool)->current; \
--        PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
-+        PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
-         PRUword _p = _a->avail; \
--        if (_nb < nb) { \
-+        if (_nb < (PRUint32)nb) { \
-             _p = 0; \
-         } else if (_nb > (_a->limit - _a->avail)) { \
-             _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
-@@ -148,27 +148,27 @@
-         } \
-         p = (void *)_p; \
-         if (p) { \
--            PL_MAKE_MEM_UNDEFINED(p, nb); \
--            PL_ArenaCountAllocation(pool, nb); \
-+            PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \
-+            PL_ArenaCountAllocation(pool, (PRUint32)nb); \
-         } \
-     PR_END_MACRO
- 
- #define PL_ARENA_GROW(p, pool, size, incr) \
-     PR_BEGIN_MACRO \
-         PLArena *_a = (pool)->current; \
--        PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
--        if (_incr < incr) { \
-+        PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
-+        if (_incr < (PRUint32)incr) { \
-             p = NULL; \
-         } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
-             _incr <= (_a->limit - _a->avail)) { \
--            PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, incr); \
-+            PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \
-             _a->avail += _incr; \
--            PL_ArenaCountInplaceGrowth(pool, size, incr); \
-+            PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \
-         } else { \
--            p = PL_ArenaGrow(pool, p, size, incr); \
-+            p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
-         } \
-         if (p) {\
--            PL_ArenaCountGrowth(pool, size, incr); \
-+            PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
-         } \
-     PR_END_MACRO
- 
diff --git a/debian/patches/Drop-fdcach-until-debugged.patch b/debian/patches/Drop-fdcach-until-debugged.patch
new file mode 100644
index 0000000..669dc25
--- /dev/null
+++ b/debian/patches/Drop-fdcach-until-debugged.patch
@@ -0,0 +1,21 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Sat, 2 Jan 2016 18:55:51 +0100
+Subject: Skip fdcach test until debugged
+
+since this fails reliably in pbuilder and outside
+---
+ nspr/pr/tests/runtests.sh | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/nspr/pr/tests/runtests.sh b/nspr/pr/tests/runtests.sh
+index 760f032..c1cf0e3 100755
+--- a/nspr/pr/tests/runtests.sh
++++ b/nspr/pr/tests/runtests.sh
+@@ -89,7 +89,6 @@ dlltest
+ dtoa
+ errcodes
+ exit
+-fdcach
+ fileio
+ foreign
+ formattm
diff --git a/debian/patches/Fix-vercheck-test.patch b/debian/patches/Fix-vercheck-test.patch
new file mode 100644
index 0000000..b7b24d3
--- /dev/null
+++ b/debian/patches/Fix-vercheck-test.patch
@@ -0,0 +1,30 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Fri, 20 May 2016 17:17:29 +0200
+Subject: Fix vercheck test
+
+4.12 must be compatible with 4.11.1
+---
+ nspr/pr/tests/vercheck.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/nspr/pr/tests/vercheck.c b/nspr/pr/tests/vercheck.c
+index b19b579..582c1a6 100644
+--- a/nspr/pr/tests/vercheck.c
++++ b/nspr/pr/tests/vercheck.c
+@@ -39,7 +39,7 @@ static char *compatible_version[] = {
+     "4.9.6",
+     "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
+     "4.10.5", "4.10.6", "4.10.7", "4.10.8", "4.10.9",
+-    "4.10.10", "4.11",
++    "4.10.10", "4.11", "4.11.1",
+     PR_VERSION
+ };
+ 
+@@ -55,7 +55,6 @@ static char *incompatible_version[] = {
+     "3.0", "3.0.1",
+     "3.1", "3.1.1", "3.1.2", "3.1.3",
+     "3.5", "3.5.1",
+-    "4.11.1",
+     "4.12.1",
+     "10.0", "11.1", "12.14.20"
+ };
diff --git a/debian/patches/Use-localhost-for-gethost-test.patch b/debian/patches/Use-localhost-for-gethost-test.patch
new file mode 100644
index 0000000..007fb98
--- /dev/null
+++ b/debian/patches/Use-localhost-for-gethost-test.patch
@@ -0,0 +1,22 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Thu, 31 Dec 2015 14:00:05 +0100
+Subject: Use localhost for gethost test
+
+otherwise we fail without a network connection
+---
+ nspr/pr/tests/gethost.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nspr/pr/tests/gethost.c b/nspr/pr/tests/gethost.c
+index 779bce4..0be4eb6 100644
+--- a/nspr/pr/tests/gethost.c
++++ b/nspr/pr/tests/gethost.c
+@@ -18,7 +18,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+-#define DEFAULT_HOST_NAME "mcom.com"
++#define DEFAULT_HOST_NAME "127.0.0.1"
+ 
+ static void Help(void)
+ {
diff --git a/debian/patches/series b/debian/patches/series
index 0b76567..c6d7746 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
-CVE-2015-7183-1.patch
-CVE-2015-7183-2.patch
+Use-localhost-for-gethost-test.patch
+Drop-fdcach-until-debugged.patch
+Fix-vercheck-test.patch
diff --git a/debian/rules b/debian/rules
index cb9ffce..46766b0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -25,8 +25,12 @@ endif
 ifeq (64,$(shell dpkg-architecture -qDEB_HOST_ARCH_BITS))
 	CONFIGURE_FLAGS += --enable-64bit
 endif
+ifeq (x32,$(shell dpkg-architecture -qDEB_HOST_ARCH))
+	CONFIGURE_FLAGS += --enable-x32
+endif
 
 $(call lazy,DEB_HOST_MULTIARCH,$$(shell dpkg-architecture -qDEB_HOST_MULTIARCH))
+$(call lazy,BUILD_DATE,$$(shell dpkg-parsechangelog -S Date))
 
 PREPROCESS_FILES := $(wildcard debian/*.in)
 
@@ -41,14 +45,20 @@ override_dh_auto_configure: $(PREPROCESS_FILES:.in=)
 		sed -i '2!b;/^#/ i\exec "/usr/share/misc/'$$file'" "$$@"' nspr/build/autoconf/$$file; \
 	done
 
+	cd nspr && \
 	CFLAGS="$(CFLAGS)" \
 	CPPFLAGS="$(CPPFLAGS)" \
 	LDFLAGS="$(LDFLAGS)" \
-	dh_auto_configure -- \
+	./configure --target=$(DEB_HOST_GNU_TYPE) --host=$(DEB_BUILD_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
                     $(CONFIGURE_FLAGS) \
 		    --prefix=/usr \
 		    --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
 
+override_dh_auto_build:
+	$(MAKE) -C nspr \
+		SH_NOW="$(shell TZ=UTC date -d "$(BUILD_DATE)" +%s)000000" \
+		SH_DATE="$(shell TZ=UTC date -d "$(BUILD_DATE)" "+%Y-%m-%d %T")"
+
 override_dh_auto_clean:
 	dh_auto_clean
 
@@ -60,10 +70,15 @@ override_dh_auto_clean:
 override_dh_strip:
 	dh_strip -a --dbg-package=libnspr4-dbg
 
-override_dh_makeshlibs: /usr/share/debhelper/autoscripts/postinst-makeshlibs /usr/share/debhelper/autoscripts/postrm-makeshlibs
+override_dh_makeshlibs:
 	dh_makeshlibs -a -- -c4
-	cat /usr/share/debhelper/autoscripts/postinst-makeshlibs > debian/libnspr4.postinst.debhelper
-	cat /usr/share/debhelper/autoscripts/postrm-makeshlibs > debian/libnspr4.postrm.debhelper
+
+override_dh_auto_test:
+	$(MAKE) -C nspr/pr/tests
+	$(MAKE) -C nspr/lib/tests
+	cd nspr/pr/tests && ./runtests.sh
+	cd nspr/lib/tests && ./base64t
+	cd nspr/lib/tests && ./string
 
 ifneq (,$(DEB_HOST_MULTIARCH))
 override_dh_gencontrol:
diff --git a/debian/watch b/debian/watch
index 010d70e..87de164 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,2 +1,2 @@
 version=3
-http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v(\d\.[\d\.]+)/src/nspr-([\d\.]+)\.tar\.gz
+https://archive.mozilla.org/pub/nspr/releases/v(\d\.[\d\.]+)/src/nspr-([\d\.]+)\.tar\.gz
diff --git a/nspr/.hg_archival.txt b/nspr/.hg_archival.txt
index 39eb26c..59d29d5 100644
--- a/nspr/.hg_archival.txt
+++ b/nspr/.hg_archival.txt
@@ -1,4 +1,4 @@
 repo: a4b34919bf34db2ee22acbbc305693c8980b6dc6
-node: 0f03651116c5b34ba48b5a5cd31234303d9806b6
+node: 88265db540d75d59e12ea8dbc34031160fce9ccc
 branch: default
-tag: NSPR_4_10_7_RTM
+tag: NSPR_4_12_RTM
diff --git a/nspr/config/rules.mk b/nspr/config/rules.mk
index cc01759..1c8fdc9 100644
--- a/nspr/config/rules.mk
+++ b/nspr/config/rules.mk
@@ -81,15 +81,20 @@ ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
 # other platforms do not.
 #
 ifeq (,$(filter-out WIN95 WINCE WINMO OS2,$(OS_TARGET)))
-LIBRARY		= $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
 SHARED_LIBRARY	= $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
-IMPORT_LIBRARY	= $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
 SHARED_LIB_PDB	= $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
+ifdef MSC_VER
+LIBRARY         = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
+IMPORT_LIBRARY  = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
+else
+LIBRARY         = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
+IMPORT_LIBRARY  = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
+endif
 else
-LIBRARY		= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
 SHARED_LIBRARY	= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
-IMPORT_LIBRARY	= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
 SHARED_LIB_PDB	= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
+LIBRARY         = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
+IMPORT_LIBRARY  = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
 endif
 
 else
@@ -359,7 +364,7 @@ endif
 ifdef MOZ_PROFILE_GENERATE
 # Clean up profiling data during PROFILE_GENERATE phase
 export::
-ifeq ($(OS_ARCH)_$(NS_USE_GCC), WINNT_)
+ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
 	$(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
 else
 ifdef NS_USE_GCC
diff --git a/nspr/configure b/nspr/configure
index 40d342c..0ff06ec 100755
--- a/nspr/configure
+++ b/nspr/configure
@@ -2488,8 +2488,8 @@ test -n "$target_alias" &&
   program_prefix=${target_alias}-
 
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=7
+MOD_MINOR_VERSION=12
+MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
@@ -2666,19 +2666,6 @@ fi
 
 if test -n "$gonkdir" ; then
 
-        if test -z "$HOST_CPPFLAGS" ; then
-        HOST_CPPFLAGS=" "
-    fi
-    if test -z "$HOST_CFLAGS" ; then
-        HOST_CFLAGS=" "
-    fi
-    if test -z "$HOST_CXXFLAGS" ; then
-        HOST_CXXFLAGS=" "
-    fi
-    if test -z "$HOST_LDFLAGS" ; then
-        HOST_LDFLAGS=" "
-    fi
-
     $as_echo "#define ANDROID 1" >>confdefs.h
 
 else
@@ -2763,19 +2750,6 @@ $as_echo "$android_platform" >&6; }
     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
 
-        if test -z "$HOST_CPPFLAGS" ; then
-        HOST_CPPFLAGS=" "
-    fi
-    if test -z "$HOST_CFLAGS" ; then
-        HOST_CFLAGS=" "
-    fi
-    if test -z "$HOST_CXXFLAGS" ; then
-        HOST_CXXFLAGS=" "
-    fi
-    if test -z "$HOST_LDFLAGS" ; then
-        HOST_LDFLAGS=" "
-    fi
-
     $as_echo "#define ANDROID 1" >>confdefs.h
 
     ;;
@@ -3152,12 +3126,6 @@ if test "$target" != "$host"; then
         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
         ;;
-      *:arm*-apple-darwin*)
-                                _SAVE_CFLAGS=$CFLAGS
-        _SAVE_CXXFLAGS=$CXXFLAGS
-        CFLAGS="-isysroot $MACOS_SDK_DIR $CFLAGS"
-        CXXFLAGS="-isysroot $MACOS_SDK_DIR $CXXFLAGS"
-        ;;
     esac
 
     for ac_prog in $CC "${target_alias}-gcc" "${target}-gcc"
@@ -4621,12 +4589,6 @@ test -n "$HOST_CC" || HOST_CC=""""
     fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOST_CC" >&5
 $as_echo "$HOST_CC" >&6; }
-    if test -z "$HOST_CFLAGS"; then
-        HOST_CFLAGS="$CFLAGS"
-    fi
-    if test -z "$HOST_LDFLAGS"; then
-        HOST_LDFLAGS="$LDFLAGS"
-    fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
@@ -6584,6 +6546,7 @@ fi
     fi
     ac_fn_c_check_header_mongrel "$LINENO" "crt_externs.h" "ac_cv_header_crt_externs_h" "$ac_includes_default"
 if test "x$ac_cv_header_crt_externs_h" = xyes; then :
+  $as_echo "#define HAVE_CRT_EXTERNS_H 1" >>confdefs.h
 
 fi
 
@@ -7085,10 +7048,6 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
             PR_MD_ASFILES=os_Linux_ppc.s
         fi
         ;;
-    m68k)
-        CFLAGS="$CFLAGS -m68020-60"
-        CXXFLAGS="$CXXFLAGS -m68020-60"
-        ;;
     esac
     ;;
 
@@ -7124,7 +7083,11 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
 
         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
 
-        CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
+        CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
+        if test -z "$CC_VERSION"; then
+            as_fn_error $? "Could not determine MSC version." "$LINENO" 5
+        fi
+
         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
@@ -7316,6 +7279,8 @@ $as_echo "$as_me: WARNING: Unknown version of the Microsoft (R) Manifest Tool."
 
     $as_echo "#define HAVE_BSD_FLOCK 1" >>confdefs.h
 
+    $as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
@@ -7382,7 +7347,7 @@ $as_echo "$as_me: WARNING: Unknown version of the Microsoft (R) Manifest Tool."
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
-    DSO_LDOPTS='-shared -fPIC'
+    DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     ;;
 
@@ -7925,7 +7890,7 @@ fi
 
 _SAVE_LIBS="$LIBS"
 LIBS="$LIBS $OS_LIBS"
-for ac_func in dladdr gettid lchown setpriority strerror syscall
+for ac_func in dladdr gettid lchown setpriority strerror syscall  secure_getenv __secure_getenv
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/nspr/configure.in b/nspr/configure.in
index fba01ae..2ab2383 100644
--- a/nspr/configure.in
+++ b/nspr/configure.in
@@ -15,8 +15,8 @@ dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=7
+MOD_MINOR_VERSION=12
+MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
@@ -160,20 +160,6 @@ AC_ARG_WITH(gonk,
 if test -n "$gonkdir" ; then
     dnl Most things are directly configured by env vars when building for gonk
 
-    dnl prevent cross compile section from using these flags as host flags
-    if test -z "$HOST_CPPFLAGS" ; then
-        HOST_CPPFLAGS=" "
-    fi
-    if test -z "$HOST_CFLAGS" ; then
-        HOST_CFLAGS=" "
-    fi
-    if test -z "$HOST_CXXFLAGS" ; then
-        HOST_CXXFLAGS=" "
-    fi
-    if test -z "$HOST_LDFLAGS" ; then
-        HOST_LDFLAGS=" "
-    fi
-
     AC_DEFINE(ANDROID)
 else
 case "$target" in
@@ -257,20 +243,6 @@ case "$target" in
     CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
     LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
 
-    dnl prevent cross compile section from using these flags as host flags
-    if test -z "$HOST_CPPFLAGS" ; then
-        HOST_CPPFLAGS=" "
-    fi
-    if test -z "$HOST_CFLAGS" ; then
-        HOST_CFLAGS=" "
-    fi
-    if test -z "$HOST_CXXFLAGS" ; then
-        HOST_CXXFLAGS=" "
-    fi
-    if test -z "$HOST_LDFLAGS" ; then
-        HOST_LDFLAGS=" "
-    fi
-
     AC_DEFINE(ANDROID)
     ;;
 esac
@@ -596,15 +568,6 @@ if test "$target" != "$host"; then
         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
         ;;
-      *:arm*-apple-darwin*)
-        dnl The arm compiler doesn't appear to know about its root by default,
-        dnl so explicitly pass it one here. Later on we'll put this in CFLAGS
-        dnl anyway.
-        _SAVE_CFLAGS=$CFLAGS
-        _SAVE_CXXFLAGS=$CXXFLAGS
-        CFLAGS="-isysroot $MACOS_SDK_DIR $CFLAGS"
-        CXXFLAGS="-isysroot $MACOS_SDK_DIR $CXXFLAGS"
-        ;;
     esac
 
     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
@@ -653,12 +616,6 @@ if test "$target" != "$host"; then
         AC_MSG_ERROR([no acceptable cc found in \$PATH])
     fi
     AC_MSG_RESULT([$HOST_CC])
-    if test -z "$HOST_CFLAGS"; then
-        HOST_CFLAGS="$CFLAGS"
-    fi
-    if test -z "$HOST_LDFLAGS"; then
-        HOST_LDFLAGS="$LDFLAGS"
-    fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
@@ -1412,7 +1369,7 @@ case "$target" in
     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
         CC="$CC -arch $CPU_ARCH"
     fi
-    AC_CHECK_HEADER(crt_externs.h)
+    AC_CHECK_HEADER(crt_externs.h, AC_DEFINE(HAVE_CRT_EXTERNS_H))
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
     _OPTIMIZE_FLAGS=-O2
@@ -1899,10 +1856,6 @@ tools are selected during the Xcode/Developer Tools installation.])
             PR_MD_ASFILES=os_Linux_ppc.s
         fi
         ;;
-    m68k)
-        CFLAGS="$CFLAGS -m68020-60"
-        CXXFLAGS="$CXXFLAGS -m68020-60"
-        ;;
     esac    
     ;;
 
@@ -1936,7 +1889,11 @@ tools are selected during the Xcode/Developer Tools installation.])
         changequote(,)
         _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p'
         changequote([,])
-        CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
+        CC_VERSION=`${CC} -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"`
+        if test -z "$CC_VERSION"; then
+            AC_MSG_ERROR([Could not determine MSC version.])
+        fi
+
         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'`
         _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'`
         _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'`
@@ -2120,6 +2077,7 @@ tools are selected during the Xcode/Developer Tools installation.])
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(NETBSD)
     AC_DEFINE(HAVE_BSD_FLOCK)
+    AC_DEFINE(HAVE_SOCKLEN_T)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
@@ -2178,7 +2136,7 @@ tools are selected during the Xcode/Developer Tools installation.])
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
-    DSO_LDOPTS='-shared -fPIC'
+    DSO_LDOPTS='-shared -fPIC -Wl,-soname,$(notdir $@)'
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     ;;
 
@@ -2581,7 +2539,8 @@ dnl ========================================================
 AC_PROG_GCC_TRADITIONAL
 _SAVE_LIBS="$LIBS"
 LIBS="$LIBS $OS_LIBS"
-AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall)
+AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
+ secure_getenv __secure_getenv)
 LIBS="$_SAVE_LIBS"
 
 dnl ========================================================
diff --git a/nspr/lib/ds/plarena.c b/nspr/lib/ds/plarena.c
index 95e1931..689496d 100644
--- a/nspr/lib/ds/plarena.c
+++ b/nspr/lib/ds/plarena.c
@@ -93,6 +93,9 @@ PR_IMPLEMENT(void) PL_InitArenaPool(
         pool->mask = PR_BITMASK(PR_CeilingLog2(align));
 
     pool->first.next = NULL;
+    /* Set all three addresses in pool->first to the same dummy value.
+     * These addresses are only compared with each other, but never
+     * dereferenced. */
     pool->first.base = pool->first.avail = pool->first.limit =
         (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
     pool->current = &pool->first;
@@ -144,10 +147,14 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
 {
     PLArena *a;   
     char *rp;     /* returned pointer */
+    PRUint32 nbOld;
 
     PR_ASSERT((nb & pool->mask) == 0);
     
+    nbOld = nb;
     nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */
+    if (nb < nbOld)
+        return NULL;
 
     /* attempt to allocate from arenas at pool->current */
     {
@@ -208,6 +215,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
             PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
             rp = (char *)a->avail;
             a->avail += nb;
+            PR_ASSERT(a->avail <= a->limit);
             /* the newly allocated arena is linked after pool->current 
             *  and becomes pool->current */
             a->next = pool->current->next;
@@ -230,6 +238,8 @@ PR_IMPLEMENT(void *) PL_ArenaGrow(
 {
     void *newp;
 
+    if (PR_UINT32_MAX - size < incr)
+        return NULL;
     PL_ARENA_ALLOCATE(newp, pool, size + incr);
     if (newp)
         memcpy(newp, p, size);
diff --git a/nspr/lib/ds/plarena.h b/nspr/lib/ds/plarena.h
index 8dcfb3e..2673a2a 100644
--- a/nspr/lib/ds/plarena.h
+++ b/nspr/lib/ds/plarena.h
@@ -96,11 +96,11 @@ struct PLArenaPool {
 
 /* These definitions are usually provided through the
  * sanitizer/asan_interface.h header installed by ASan.
- * See https://code.google.com/p/address-sanitizer/wiki/ManualPoisoning
+ * See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
  */
 
-void __asan_poison_memory_region(void const volatile *addr, size_t size);
-void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
+PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
+PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
 
 #define PL_MAKE_MEM_NOACCESS(addr, size) \
     __asan_poison_memory_region((addr), (size))
@@ -137,34 +137,39 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
 #define PL_ARENA_ALLOCATE(p, pool, nb) \
     PR_BEGIN_MACRO \
         PLArena *_a = (pool)->current; \
-        PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
+        PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
         PRUword _p = _a->avail; \
-        PRUword _q = _p + _nb; \
-        if (_q > _a->limit) { \
+        if (_nb < (PRUint32)nb) { \
+            _p = 0; \
+        } else if (_nb > (_a->limit - _a->avail)) { \
             _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
         } else { \
-            _a->avail = _q; \
+            _a->avail += _nb; \
         } \
         p = (void *)_p; \
-        PL_MAKE_MEM_UNDEFINED(p, nb); \
-        PL_ArenaCountAllocation(pool, nb); \
+        if (p) { \
+            PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \
+            PL_ArenaCountAllocation(pool, (PRUint32)nb); \
+        } \
     PR_END_MACRO
 
 #define PL_ARENA_GROW(p, pool, size, incr) \
     PR_BEGIN_MACRO \
         PLArena *_a = (pool)->current; \
-        PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
-        PRUword _p = _a->avail; \
-        PRUword _q = _p + _incr; \
-        if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
-            _q <= _a->limit) { \
-            PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, incr); \
-            _a->avail = _q; \
-            PL_ArenaCountInplaceGrowth(pool, size, incr); \
+        PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
+        if (_incr < (PRUint32)incr) { \
+            p = NULL; \
+        } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
+            _incr <= (_a->limit - _a->avail)) { \
+            PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \
+            _a->avail += _incr; \
+            PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \
         } else { \
-            p = PL_ArenaGrow(pool, p, size, incr); \
+            p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
+        } \
+        if (p) {\
+            PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
         } \
-        PL_ArenaCountGrowth(pool, size, incr); \
     PR_END_MACRO
 
 #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
diff --git a/nspr/pr/include/md/_freebsd.cfg b/nspr/pr/include/md/_freebsd.cfg
index c120460..1d1039a 100644
--- a/nspr/pr/include/md/_freebsd.cfg
+++ b/nspr/pr/include/md/_freebsd.cfg
@@ -251,6 +251,295 @@
 #define PR_ALIGN_OF_POINTER 8
 #define PR_ALIGN_OF_WORD    8
 
+#elif defined(__powerpc64__)
+
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#elif defined(__powerpc__)
+
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#elif defined(__aarch64__)
+
+#undef  IS_BIG_ENDIAN
+#define IS_LITTLE_ENDIAN 1
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2  3
+#define PR_BYTES_PER_DWORD_LOG2 3
+
+#elif defined(__arm__)
+
+#if defined(__ARMEB__) || defined(__ARM_BIG_ENDIAN__)
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+#else
+#undef  IS_BIG_ENDIAN
+#define IS_LITTLE_ENDIAN 1
+#endif
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#elif defined(__mips64__)
+
+#if defined(__MIPSEB__) || defined(_MIPSEB)
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+#else
+#undef  IS_BIG_ENDIAN
+#define IS_LITTLE_ENDIAN 1
+#endif
+
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#elif defined(__mips__)
+
+#if defined(__MIPSEB__) || defined(_MIPSEB)
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+#else
+#undef  IS_BIG_ENDIAN
+#define IS_LITTLE_ENDIAN 1
+#endif
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
 #else
 
 #error "Unknown CPU architecture"
diff --git a/nspr/pr/include/md/_freebsd.h b/nspr/pr/include/md/_freebsd.h
index 1ea7b60..9a179bc 100644
--- a/nspr/pr/include/md/_freebsd.h
+++ b/nspr/pr/include/md/_freebsd.h
@@ -25,6 +25,18 @@
 #define _PR_SI_ARCHITECTURE "ia64"
 #elif defined(__amd64__)
 #define _PR_SI_ARCHITECTURE "amd64"
+#elif defined(__powerpc64__)
+#define _PR_SI_ARCHITECTURE "powerpc64"
+#elif defined(__powerpc__)
+#define _PR_SI_ARCHITECTURE "powerpc"
+#elif defined(__aarch64__)
+#define _PR_SI_ARCHITECTURE "aarch64"
+#elif defined(__arm__)
+#define _PR_SI_ARCHITECTURE "arm"
+#elif defined(__mips64__)
+#define _PR_SI_ARCHITECTURE "mips64"
+#elif defined(__mips__)
+#define _PR_SI_ARCHITECTURE "mips"
 #else
 #error "Unknown CPU architecture"
 #endif
@@ -218,7 +230,7 @@ extern void _MD_EarlyInit(void);
 
 #define _MD_EARLY_INIT                  _MD_EarlyInit
 #define _MD_FINAL_INIT			_PR_UnixInit
-#define _MD_INTERVAL_USE_GTOD
+#define _PR_HAVE_CLOCK_MONOTONIC
 
 /*
  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
diff --git a/nspr/pr/include/md/_linux.cfg b/nspr/pr/include/md/_linux.cfg
index 1d09b31..8cbf0cb 100644
--- a/nspr/pr/include/md/_linux.cfg
+++ b/nspr/pr/include/md/_linux.cfg
@@ -508,6 +508,52 @@
 #error "Unknown MIPS endianness."
 #endif
 
+#if _MIPS_SIM == _ABI64
+
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#else /* _ABI64 */
+
 #define PR_BYTES_PER_BYTE   1
 #define PR_BYTES_PER_SHORT  2
 #define PR_BYTES_PER_INT    4
@@ -548,6 +594,8 @@
 #define PR_BYTES_PER_WORD_LOG2   2
 #define PR_BYTES_PER_DWORD_LOG2  3
 
+#endif /* _ABI64 */
+
 #elif defined(__arm__)
 
 #ifdef __ARMEB__
@@ -924,6 +972,51 @@
 #define PR_BYTES_PER_WORD_LOG2   2
 #define PR_BYTES_PER_DWORD_LOG2  3
 
+#elif defined(__or1k__)
+
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN 1
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   4
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
 #else
 
 #error "Unknown CPU architecture"
diff --git a/nspr/pr/include/md/_linux.h b/nspr/pr/include/md/_linux.h
index 278f90c..b4b298b 100644
--- a/nspr/pr/include/md/_linux.h
+++ b/nspr/pr/include/md/_linux.h
@@ -55,6 +55,8 @@
 #define _PR_SI_ARCHITECTURE "avr32"
 #elif defined(__m32r__)
 #define _PR_SI_ARCHITECTURE "m32r"
+#elif defined(__or1k__)
+#define _PR_SI_ARCHITECTURE "or1k"
 #else
 #error "Unknown CPU architecture"
 #endif
@@ -65,7 +67,7 @@
 #define _MD_DEFAULT_STACK_SIZE	65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__mips__)
 #define _MD_MINIMUM_STACK_SIZE  0x20000
 #endif
 
@@ -123,6 +125,18 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
 #define _MD_ATOMIC_SET                _PR_x86_64_AtomicSet
 #endif
 
+#if defined(__or1k__)
+#if defined(__GNUC__)
+/* Use GCC built-in functions */
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+#define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
+#define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)
+#define _MD_ATOMIC_ADD(ptr, i) __sync_add_and_fetch(ptr, i)
+#define _MD_ATOMIC_SET(ptr, nv) __sync_lock_test_and_set(ptr, nv)
+#endif
+#endif
+
 #if defined(__powerpc__) && !defined(__powerpc64__)
 #define _PR_HAVE_ATOMIC_OPS
 #define _MD_INIT_ATOMIC()
@@ -148,6 +162,16 @@ extern PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);
 #endif
 #endif
 
+#if defined(__mips__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
+/* Use GCC built-in functions */
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+#define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
+#define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)
+#define _MD_ATOMIC_ADD(ptr, i) __sync_add_and_fetch(ptr, i)
+#define _MD_ATOMIC_SET(ptr, nv) __sync_lock_test_and_set(ptr, nv)
+#endif
+
 #if defined(__alpha)
 #define _PR_HAVE_ATOMIC_OPS
 #define _MD_INIT_ATOMIC()
@@ -647,7 +671,7 @@ extern void _MD_EarlyInit(void);
 
 #define _MD_EARLY_INIT                  _MD_EarlyInit
 #define _MD_FINAL_INIT                  _PR_UnixInit
-#define HAVE_CLOCK_MONOTONIC
+#define _PR_HAVE_CLOCK_MONOTONIC
 
 /*
  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
diff --git a/nspr/pr/include/md/_netbsd.h b/nspr/pr/include/md/_netbsd.h
index 8b8e8dd..945d94f 100644
--- a/nspr/pr/include/md/_netbsd.h
+++ b/nspr/pr/include/md/_netbsd.h
@@ -211,7 +211,7 @@ extern void _MD_EarlyInit(void);
 
 #define _MD_EARLY_INIT                  _MD_EarlyInit
 #define _MD_FINAL_INIT			_PR_UnixInit
-#define _MD_INTERVAL_USE_GTOD
+#define _PR_HAVE_CLOCK_MONOTONIC
 
 /*
  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
diff --git a/nspr/pr/include/md/_openbsd.h b/nspr/pr/include/md/_openbsd.h
index e014088..666c177 100644
--- a/nspr/pr/include/md/_openbsd.h
+++ b/nspr/pr/include/md/_openbsd.h
@@ -192,7 +192,7 @@ struct _MDCPU {
 
 #define _MD_EARLY_INIT                  _MD_EarlyInit
 #define _MD_FINAL_INIT			_PR_UnixInit
-#define _MD_INTERVAL_USE_GTOD
+#define _PR_HAVE_CLOCK_MONOTONIC
 
 /*
  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
diff --git a/nspr/pr/include/md/_unixos.h b/nspr/pr/include/md/_unixos.h
index 04d9904..ea46b3a 100644
--- a/nspr/pr/include/md/_unixos.h
+++ b/nspr/pr/include/md/_unixos.h
@@ -302,7 +302,7 @@ extern PRIntervalTime   _PR_UNIX_TicksPerSecond(void);
 #define _MD_INTERVAL_PER_SEC		_PR_UNIX_TicksPerSecond
 #endif
 
-#ifdef HAVE_CLOCK_MONOTONIC
+#ifdef _PR_HAVE_CLOCK_MONOTONIC
 extern PRIntervalTime   _PR_UNIX_GetInterval2(void);
 extern PRIntervalTime   _PR_UNIX_TicksPerSecond2(void);
 #define _MD_INTERVAL_INIT()
diff --git a/nspr/pr/include/pratom.h b/nspr/pr/include/pratom.h
index 9dbe0fa..dff9d6c 100644
--- a/nspr/pr/include/pratom.h
+++ b/nspr/pr/include/pratom.h
@@ -107,7 +107,9 @@ NSPR_API(PRInt32)	PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
            defined(__powerpc__) || \
            (defined(__arm__) && \
            defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
-           defined(__aarch64__) || defined(__alpha))))
+           defined(__aarch64__) || defined(__alpha) || \
+           (defined(__mips__) && \
+           defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)))))
 
 /*
  * Because the GCC manual warns that some processors may support
diff --git a/nspr/pr/include/prenv.h b/nspr/pr/include/prenv.h
index 524fc75..468c7d5 100644
--- a/nspr/pr/include/prenv.h
+++ b/nspr/pr/include/prenv.h
@@ -91,6 +91,20 @@ PR_BEGIN_EXTERN_C
 NSPR_API(char*) PR_GetEnv(const char *var);
 
 /*
+** PR_GetEnvSecure() -- get a security-sensitive environment variable
+**
+** Description:
+**
+** PR_GetEnvSecure() is similar to PR_GetEnv(), but it returns NULL if
+** the program was run with elevated privilege (e.g., setuid or setgid
+** on Unix).  This can be used for cases like log file paths which
+** could otherwise be used for privilege escalation.  Note that some
+** platforms may have platform-specific privilege elevation mechanisms
+** not recognized by this function; see the implementation for details.
+*/
+NSPR_API(char*) PR_GetEnvSecure(const char *var);
+
+/*
 ** PR_SetEnv() -- set, unset or change an environment variable
 ** 
 ** Description:
@@ -113,6 +127,36 @@ NSPR_API(char*) PR_GetEnv(const char *var);
 */
 NSPR_API(PRStatus) PR_SetEnv(const char *string);
 
+/*
+** PR_DuplicateEnvironment() -- Obtain a copy of the environment.
+**
+** Description:
+** PR_DuplicateEnvironment() copies the environment so that it can be
+** modified without changing the current process's environment, and
+** then passed to interfaces such as POSIX execve().  In particular,
+** this avoids needing to allocate memory or take locks in the child
+** after a fork(); neither of these is allowed by POSIX after a
+** multithreaded process calls fork(), and PR_SetEnv does both.
+**
+** Inputs:
+**   none
+**
+** Returns:
+**   A pointer to a null-terminated array of null-terminated strings,
+**   like the traditional global variable "environ".  The array and
+**   the strings are allocated with PR_Malloc(), and it is the
+**   caller's responsibility to free them.
+**
+**   In case of memory allocation failure, or if the operating system
+**   doesn't support reading the entire environment through the global
+**   variable "environ" or similar, returns NULL instead.
+**
+** Restrictions:
+**   Similarly to PR_GetEnv(), this function may not interoperate as
+**   expected with the operating system's native environment accessors.
+*/
+NSPR_API(char **) PR_DuplicateEnvironment(void);
+
 PR_END_EXTERN_C
 
 #endif /* prenv_h___ */
diff --git a/nspr/pr/include/prinit.h b/nspr/pr/include/prinit.h
index a2b1365..523c2b9 100644
--- a/nspr/pr/include/prinit.h
+++ b/nspr/pr/include/prinit.h
@@ -31,10 +31,10 @@ PR_BEGIN_EXTERN_C
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.10.7"
+#define PR_VERSION  "4.12"
 #define PR_VMAJOR   4
-#define PR_VMINOR   10
-#define PR_VPATCH   7
+#define PR_VMINOR   12
+#define PR_VPATCH   0
 #define PR_BETA     PR_FALSE
 
 /*
diff --git a/nspr/pr/include/prlog.h b/nspr/pr/include/prlog.h
index 6f825f2..4a291dc 100644
--- a/nspr/pr/include/prlog.h
+++ b/nspr/pr/include/prlog.h
@@ -157,7 +157,8 @@ NSPR_API(void) PR_LogPrint(const char *fmt, ...);
 */
 NSPR_API(void) PR_LogFlush(void);
 
-NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln);
+NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln)
+    PR_PRETEND_NORETURN;
 
 #if defined(DEBUG) || defined(FORCE_PR_LOG)
 #define PR_LOGGING 1
diff --git a/nspr/pr/include/prtime.h b/nspr/pr/include/prtime.h
index 732990e..caaee14 100644
--- a/nspr/pr/include/prtime.h
+++ b/nspr/pr/include/prtime.h
@@ -248,14 +248,14 @@ NSPR_API(PRStatus) PR_ParseTimeString (
 
 /* Format a time value into a buffer. Same semantics as strftime() */
 NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,
-                                           const PRExplodedTime *tm);
+                                 const PRExplodedTime *time);
 
-/* Format a time value into a buffer. Time is always in US English format, regardless
- * of locale setting.
+/* Format a time value into a buffer. Time is always in US English format,
+ * regardless of locale setting.
  */
 NSPR_API(PRUint32)
-PR_FormatTimeUSEnglish( char* buf, PRUint32 bufSize,
-                        const char* format, const PRExplodedTime* tm );
+PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize,
+                       const char *format, const PRExplodedTime *time);
 
 PR_END_EXTERN_C
 
diff --git a/nspr/pr/include/prtypes.h b/nspr/pr/include/prtypes.h
index a5069bb..52b3ab0 100644
--- a/nspr/pr/include/prtypes.h
+++ b/nspr/pr/include/prtypes.h
@@ -510,6 +510,31 @@ typedef long PRWord;
 typedef unsigned long PRUword;
 #endif
 
+/*
+ * PR_PRETEND_NORETURN, specified at the end of a function declaration,
+ * indicates that for the purposes of static analysis, this function does not
+ * return.  (The function definition does not need to be annotated.)
+ *
+ * void PR_Assert(const char *s, const char *file, PRIntn ln)
+ *     PR_PRETEND_NORETURN;
+ *
+ * Some static analyzers, like scan-build from clang, can use this information
+ * to eliminate false positives.  From the upstream documentation of
+ * scan-build:
+ *     This attribute is useful for annotating assertion handlers that actually
+ *     can return, but for the purpose of using the analyzer we want to pretend
+ *     that such functions do not return.
+ */
+#ifdef __clang_analyzer__
+#if __has_extension(attribute_analyzer_noreturn)
+#define PR_PRETEND_NORETURN __attribute__((analyzer_noreturn))
+#endif
+#endif
+
+#ifndef PR_PRETEND_NORETURN
+#define PR_PRETEND_NORETURN /* no support */
+#endif
+
 #if defined(NO_NSPR_10_SUPPORT)
 #else
 /********* ???????????????? FIX ME       ??????????????????????????? *****/
diff --git a/nspr/pr/src/Makefile.in b/nspr/pr/src/Makefile.in
index e656ccc..48b6fae 100644
--- a/nspr/pr/src/Makefile.in
+++ b/nspr/pr/src/Makefile.in
@@ -165,9 +165,9 @@ endif
 
 ifeq ($(OS_ARCH),WINNT)
 ifdef NS_USE_GCC
-OS_LIBS		= -ladvapi32 -lws2_32 -lwinmm
+OS_LIBS		= -ladvapi32 -lws2_32 -lmswsock -lwinmm
 else
-OS_LIBS		= advapi32.lib ws2_32.lib winmm.lib
+OS_LIBS		= advapi32.lib ws2_32.lib mswsock.lib winmm.lib
 endif
 endif
 
diff --git a/nspr/pr/src/cplus/rcnetdb.cpp b/nspr/pr/src/cplus/rcnetdb.cpp
index f8bd0ac..042943b 100644
--- a/nspr/pr/src/cplus/rcnetdb.cpp
+++ b/nspr/pr/src/cplus/rcnetdb.cpp
@@ -35,7 +35,7 @@ RCNetAddr::RCNetAddr(RCNetAddr::HostValue host, PRUint16 port): RCBase()
     {
         case RCNetAddr::any: how = PR_IpAddrAny; break;
         case RCNetAddr::loopback: how = PR_IpAddrLoopback; break;
-        default: PR_ASSERT(!"This can't happen -- and did!");
+        default: PR_NOT_REACHED("This can't happen -- and did!");
     }
     (void)PR_InitializeNetAddr(how, port, &address);
 }  /* RCNetAddr::RCNetAddr */
diff --git a/nspr/pr/src/io/prfdcach.c b/nspr/pr/src/io/prfdcach.c
index 9ca84dc..17b71fe 100644
--- a/nspr/pr/src/io/prfdcach.c
+++ b/nspr/pr/src/io/prfdcach.c
@@ -31,13 +31,11 @@ typedef struct _PR_Fd_Cache
 {
     PRLock *ml;
     PRIntn count;
-    PRStack *stack;
     PRFileDesc *head, *tail;
     PRIntn limit_low, limit_high;
 } _PR_Fd_Cache;
 
 static _PR_Fd_Cache _pr_fd_cache;
-static PRFileDesc **stack2fd = &(((PRFileDesc*)NULL)->higher);
 
 
 /*
@@ -59,11 +57,7 @@ PRFileDesc *_PR_Getfd(void)
     */
     if (0 == _pr_fd_cache.limit_high)
     {
-        PRStackElem *pop;
-        PR_ASSERT(NULL != _pr_fd_cache.stack);
-        pop = PR_StackPop(_pr_fd_cache.stack);
-        if (NULL == pop) goto allocate;
-        fd = (PRFileDesc*)((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
+        goto allocate;
     }
     else
     {
@@ -128,18 +122,9 @@ void _PR_Putfd(PRFileDesc *fd)
     fd->identity = PR_INVALID_IO_LAYER;
     fd->secret->state = _PR_FILEDESC_FREED;
 
-    if (0 == _pr_fd_cache.limit_high)
-    {
-        PR_StackPush(_pr_fd_cache.stack, (PRStackElem*)(&fd->higher));
-    }
-    else
+    if (0 != _pr_fd_cache.limit_high)
     {
-        if (_pr_fd_cache.count > _pr_fd_cache.limit_high)
-        {
-            PR_Free(fd->secret);
-            PR_Free(fd);
-        }
-        else
+        if (_pr_fd_cache.count < _pr_fd_cache.limit_high)
         {
             PR_Lock(_pr_fd_cache.ml);
             if (NULL == _pr_fd_cache.tail)
@@ -157,8 +142,12 @@ void _PR_Putfd(PRFileDesc *fd)
             fd->higher = NULL;  /* always so */
             _pr_fd_cache.count += 1;  /* count the new entry */
             PR_Unlock(_pr_fd_cache.ml);
+            return;
         }
     }
+
+    PR_Free(fd->secret);
+    PR_Free(fd);
 }  /* _PR_Putfd */
 
 PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
@@ -173,48 +162,8 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
     if (low > high) low = high;  /* sanity check the params */
     
     PR_Lock(_pr_fd_cache.ml);
-    if (0 == high)  /* shutting down or staying down */
-    {
-        if (0 != _pr_fd_cache.limit_high)  /* shutting down */
-        {
-            _pr_fd_cache.limit_high = 0;  /* stop use */
-            /*
-            ** Hold the lock throughout - nobody's going to want it
-            ** other than another caller to this routine. Just don't
-            ** let that happen.
-            **
-            ** Put all the cached fds onto the new cache.
-            */
-            while (NULL != _pr_fd_cache.head)
-            {
-                PRFileDesc *fd = _pr_fd_cache.head;
-                _pr_fd_cache.head = fd->higher;
-                PR_StackPush(_pr_fd_cache.stack, (PRStackElem*)(&fd->higher));
-            }
-            _pr_fd_cache.limit_low = 0;
-            _pr_fd_cache.tail = NULL;
-            _pr_fd_cache.count = 0;
-        }
-    }
-    else  /* starting up or just adjusting parameters */
-    {
-        PRBool was_using_stack = (0 == _pr_fd_cache.limit_high);
-        _pr_fd_cache.limit_low = low;
-        _pr_fd_cache.limit_high = high;
-        if (was_using_stack)  /* was using stack - feed into cache */
-        {
-            PRStackElem *pop;
-            while (NULL != (pop = PR_StackPop(_pr_fd_cache.stack)))
-            {
-                PRFileDesc *fd = (PRFileDesc*)
-                    ((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
-                if (NULL == _pr_fd_cache.tail) _pr_fd_cache.tail = fd;
-                fd->higher = _pr_fd_cache.head;
-                _pr_fd_cache.head = fd;
-                _pr_fd_cache.count += 1;
-            }
-        }
-    }
+    _pr_fd_cache.limit_high = high;
+    _pr_fd_cache.limit_low = low;
     PR_Unlock(_pr_fd_cache.ml);
     return PR_SUCCESS;
 }  /* PR_SetFDCacheSize */
@@ -258,15 +207,12 @@ void _PR_InitFdCache(void)
 
     _pr_fd_cache.ml = PR_NewLock();
     PR_ASSERT(NULL != _pr_fd_cache.ml);
-    _pr_fd_cache.stack = PR_CreateStack("FD");
-    PR_ASSERT(NULL != _pr_fd_cache.stack);
 
 }  /* _PR_InitFdCache */
 
 void _PR_CleanupFdCache(void)
 {
     PRFileDesc *fd, *next;
-    PRStackElem *pop;
 
     for (fd = _pr_fd_cache.head; fd != NULL; fd = next)
     {
@@ -279,14 +225,6 @@ void _PR_CleanupFdCache(void)
     _pr_fd_cache.count = 0;
     PR_DestroyLock(_pr_fd_cache.ml);
     _pr_fd_cache.ml = NULL;
-    while ((pop = PR_StackPop(_pr_fd_cache.stack)) != NULL)
-    {
-        fd = (PRFileDesc*)((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
-        PR_DELETE(fd->secret);
-        PR_DELETE(fd);
-    }
-    PR_DestroyStack(_pr_fd_cache.stack);
-    _pr_fd_cache.stack = NULL;
 }  /* _PR_CleanupFdCache */
 
 /* prfdcach.c */
diff --git a/nspr/pr/src/io/priometh.c b/nspr/pr/src/io/priometh.c
index f254328..4208767 100644
--- a/nspr/pr/src/io/priometh.c
+++ b/nspr/pr/src/io/priometh.c
@@ -51,14 +51,14 @@ PRIOMethods _pr_faulty_methods = {
 
 PRIntn _PR_InvalidInt(void)
 {
-    PR_ASSERT(!"I/O method is invalid");
+    PR_NOT_REACHED("I/O method is invalid");
     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
     return -1;
 }  /* _PR_InvalidInt */
 
 PRInt16 _PR_InvalidInt16(void)
 {
-    PR_ASSERT(!"I/O method is invalid");
+    PR_NOT_REACHED("I/O method is invalid");
     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
     return -1;
 }  /* _PR_InvalidInt */
@@ -67,7 +67,7 @@ PRInt64 _PR_InvalidInt64(void)
 {
     PRInt64 rv;
     LL_I2L(rv, -1);
-    PR_ASSERT(!"I/O method is invalid");
+    PR_NOT_REACHED("I/O method is invalid");
     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
     return rv;
 }  /* _PR_InvalidInt */
@@ -78,7 +78,7 @@ PRInt64 _PR_InvalidInt64(void)
 
 PRStatus _PR_InvalidStatus(void)
 {
-    PR_ASSERT(!"I/O method is invalid");
+    PR_NOT_REACHED("I/O method is invalid");
     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
     return PR_FAILURE;
 }  /* _PR_InvalidDesc */
@@ -89,7 +89,7 @@ PRStatus _PR_InvalidStatus(void)
 
 PRFileDesc *_PR_InvalidDesc(void)
 {
-    PR_ASSERT(!"I/O method is invalid");
+    PR_NOT_REACHED("I/O method is invalid");
     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
     return NULL;
 }  /* _PR_InvalidDesc */
diff --git a/nspr/pr/src/io/prlog.c b/nspr/pr/src/io/prlog.c
index eec95e8..6098460 100644
--- a/nspr/pr/src/io/prlog.c
+++ b/nspr/pr/src/io/prlog.c
@@ -238,13 +238,7 @@ void _PR_InitLog(void)
         }
         PR_SetLogBuffering(isSync ? 0 : bufSize);
 
-#ifdef XP_UNIX
-        if ((getuid() != geteuid()) || (getgid() != getegid())) {
-            return;
-        }
-#endif /* XP_UNIX */
-
-        ev = PR_GetEnv("NSPR_LOG_FILE");
+        ev = PR_GetEnvSecure("NSPR_LOG_FILE");
         if (ev && ev[0]) {
             if (!PR_SetLogFile(ev)) {
 #ifdef XP_PC
@@ -537,6 +531,9 @@ PR_IMPLEMENT(void) PR_LogFlush(void)
 PR_IMPLEMENT(void) PR_Abort(void)
 {
     PR_LogPrint("Aborting");
+#ifdef ANDROID
+    __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
+#endif
     abort();
 }
 
@@ -547,9 +544,11 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln)
     fflush(stderr);
 #ifdef WIN32
     DebugBreak();
-#endif
-#ifdef XP_OS2
+#elif defined(XP_OS2)
     asm("int $3");
+#elif defined(ANDROID)
+    __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n",
+                         s, file, ln);
 #endif
     abort();
 }
diff --git a/nspr/pr/src/io/prmwait.c b/nspr/pr/src/io/prmwait.c
index 78813c4..ab32fb5 100644
--- a/nspr/pr/src/io/prmwait.c
+++ b/nspr/pr/src/io/prmwait.c
@@ -475,6 +475,7 @@ static PRStatus _MW_PollInternal(PRWaitGroup *group)
             PR_Lock(group->ml);
             if (_prmw_running != group->state)
             {
+                PR_DELETE(poll_list);
                 PR_SetError(PR_INVALID_STATE_ERROR, 0);
                 goto aborted;
             }
@@ -658,7 +659,7 @@ static void NT_TimeProc(void *arg)
         if (closesocket(bottom->secret->md.osfd) == SOCKET_ERROR)
         {
             fprintf(stderr, "closesocket failed: %d\n", WSAGetLastError());
-            PR_ASSERT(!"What shall I do?");
+            PR_NOT_REACHED("What shall I do?");
         }
     }
     return;
diff --git a/nspr/pr/src/io/prprf.c b/nspr/pr/src/io/prprf.c
index a2eb417..798ea2a 100644
--- a/nspr/pr/src/io/prprf.c
+++ b/nspr/pr/src/io/prprf.c
@@ -18,7 +18,7 @@
 #include "prlog.h"
 #include "prmem.h"
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
 #define snprintf _snprintf
 #endif
 
@@ -37,7 +37,7 @@ struct SprintfStateStr {
 
     char *base;
     char *cur;
-    PRUint32 maxlen;
+    PRUint32 maxlen;  /* Must not exceed PR_INT32_MAX. */
 
     int (*func)(void *arg, const char *sp, PRUint32 len);
     void *arg;
@@ -66,7 +66,11 @@ struct NumArg {
 
 #define NAS_DEFAULT_NUM 20  /* default number of NumberedArgument array */
 
-
+/*
+** For numeric types, the signed versions must have even values,
+** and their corresponding unsigned versions must have the subsequent
+** odd value.
+*/
 #define TYPE_INT16	0
 #define TYPE_UINT16	1
 #define TYPE_INTN	2
@@ -376,8 +380,8 @@ static int cvt_s(SprintfState *ss, const char *str, int width, int prec,
 
 /*
 ** BuildArgArray stands for Numbered Argument list Sprintf
-** for example,  
-**	fmp = "%4$i, %2$d, %3s, %1d";
+** for example,
+**	fmt = "%4$i, %2$d, %3s, %1d";
 ** the number must start from 1, and no gap among them
 */
 
@@ -515,6 +519,15 @@ static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc
 	        nas[cn].type = TYPE_INT64;
 	        c = *p++;
 	    }
+	} else if (c == 'z') {
+	    if (sizeof(size_t) == sizeof(PRInt32)) {
+	        nas[ cn ].type = TYPE_INT32;
+	    } else if (sizeof(size_t) == sizeof(PRInt64)) {
+	        nas[ cn ].type = TYPE_INT64;
+	    } else {
+		nas[ cn ].type = TYPE_UNKNOWN;
+	    }
+	    c = *p++;
 	}
 
 	/* format */
@@ -684,7 +697,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
     char *hexp;
     int rv, i;
     struct NumArg* nas = NULL;
-    struct NumArg* nap;
+    struct NumArg* nap = NULL;
     struct NumArg  nasArray[ NAS_DEFAULT_NUM ];
     char  pattern[20];
     const char* dolPt = NULL;  /* in "%4$.2f", dolPt will point to . */
@@ -809,6 +822,13 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
 		type = TYPE_INT64;
 		c = *fmt++;
 	    }
+	} else if (c == 'z') {
+	    if (sizeof(size_t) == sizeof(PRInt32)) {
+	    	type = TYPE_INT32;
+	    } else if (sizeof(size_t) == sizeof(PRInt64)) {
+	    	type = TYPE_INT64;
+	    }
+	    c = *fmt++;
 	}
 
 	/* format */
@@ -1040,6 +1060,13 @@ static int FuncStuff(SprintfState *ss, const char *sp, PRUint32 len)
 {
     int rv;
 
+    /*
+    ** We will add len to ss->maxlen at the end of the function. First check
+    ** if ss->maxlen + len would overflow or be greater than PR_INT32_MAX.
+    */
+    if (PR_UINT32_MAX - ss->maxlen < len || ss->maxlen + len > PR_INT32_MAX) {
+	return -1;
+    }
     rv = (*ss->func)(ss->arg, sp, len);
     if (rv < 0) {
 	return rv;
@@ -1085,9 +1112,21 @@ static int GrowStuff(SprintfState *ss, const char *sp, PRUint32 len)
     PRUint32 newlen;
 
     off = ss->cur - ss->base;
+    if (PR_UINT32_MAX - len < off) {
+	/* off + len would be too big. */
+	return -1;
+    }
     if (off + len >= ss->maxlen) {
 	/* Grow the buffer */
-	newlen = ss->maxlen + ((len > 32) ? len : 32);
+	PRUint32 increment = (len > 32) ? len : 32;
+	if (PR_UINT32_MAX - ss->maxlen < increment) {
+	    /* ss->maxlen + increment would overflow. */
+	    return -1;
+	}
+	newlen = ss->maxlen + increment;
+	if (newlen > PR_INT32_MAX) {
+	    return -1;
+	}
 	if (ss->base) {
 	    newbase = (char*) PR_REALLOC(ss->base, newlen);
 	} else {
@@ -1190,8 +1229,8 @@ PR_IMPLEMENT(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen,const char *fmt,
     SprintfState ss;
     PRUint32 n;
 
-    PR_ASSERT((PRInt32)outlen > 0);
-    if ((PRInt32)outlen <= 0) {
+    PR_ASSERT(outlen != 0 && outlen <= PR_INT32_MAX);
+    if (outlen == 0 || outlen > PR_INT32_MAX) {
 	return 0;
     }
 
@@ -1227,7 +1266,10 @@ PR_IMPLEMENT(char *) PR_vsprintf_append(char *last, const char *fmt, va_list ap)
 
     ss.stuff = GrowStuff;
     if (last) {
-	int lastlen = strlen(last);
+	size_t lastlen = strlen(last);
+	if (lastlen > PR_INT32_MAX) {
+	    return 0;
+	}
 	ss.base = last;
 	ss.cur = last + lastlen;
 	ss.maxlen = lastlen;
diff --git a/nspr/pr/src/io/prscanf.c b/nspr/pr/src/io/prscanf.c
index b95d656..9d75d82 100644
--- a/nspr/pr/src/io/prscanf.c
+++ b/nspr/pr/src/io/prscanf.c
@@ -194,7 +194,7 @@ static PRStatus
 GetInt(ScanfState *state, int code)
 {
     char buf[FMAX + 1], *p;
-    int ch;
+    int ch = 0;
     static const char digits[] = "0123456789abcdefABCDEF";
     PRBool seenDigit = PR_FALSE;
     int base;
@@ -304,7 +304,7 @@ static PRStatus
 GetFloat(ScanfState *state)
 {
     char buf[FMAX + 1], *p;
-    int ch;
+    int ch = 0;
     PRBool seenDigit = PR_FALSE;
 
     if (state->width == 0 || state->width > FMAX) {
diff --git a/nspr/pr/src/linking/prlink.c b/nspr/pr/src/linking/prlink.c
index d9ad10a..4715460 100644
--- a/nspr/pr/src/linking/prlink.c
+++ b/nspr/pr/src/linking/prlink.c
@@ -1036,7 +1036,7 @@ PR_UnloadLibrary(PRLibrary *lib)
          * fail (the library is not on the _pr_loadmap list),
          * but don't wipe out an error from dlclose/shl_unload.
          */
-        PR_ASSERT(!"_pr_loadmap and lib->refCount inconsistent");
+        PR_NOT_REACHED("_pr_loadmap and lib->refCount inconsistent");
         if (result == 0) {
             PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
             status = PR_FAILURE;
diff --git a/nspr/pr/src/md/os2/os2thred.c b/nspr/pr/src/md/os2/os2thred.c
index b918a74..edb9f5f 100644
--- a/nspr/pr/src/md/os2/os2thred.c
+++ b/nspr/pr/src/md/os2/os2thred.c
@@ -272,7 +272,7 @@ PR_EXTERN(PRInt32)
 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask )
 {
    /* Can we do this on OS/2?  Only on SMP versions? */
-   PR_ASSERT(!"Not implemented");
+   PR_NOT_REACHED("Not implemented");
    return 0;
 
  /* This is what windows does:
@@ -288,7 +288,7 @@ PR_EXTERN(PRInt32)
 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask)
 {
    /* Can we do this on OS/2?  Only on SMP versions? */
-   PR_ASSERT(!"Not implemented");
+   PR_NOT_REACHED("Not implemented");
    return 0;
 
  /* This is what windows does:
diff --git a/nspr/pr/src/md/unix/unix.c b/nspr/pr/src/md/unix/unix.c
index 4f27b82..fdae119 100644
--- a/nspr/pr/src/md/unix/unix.c
+++ b/nspr/pr/src/md/unix/unix.c
@@ -2715,7 +2715,7 @@ static void* _MD_Unix_mmap64(
 
 /* Android <= 19 doesn't have mmap64. */
 #if defined(ANDROID) && __ANDROID_API__ <= 19
-extern void *__mmap2(void *, size_t, int, int, int, size_t);
+PR_IMPORT(void) *__mmap2(void *, size_t, int, int, int, size_t);
 
 #define ANDROID_PAGE_SIZE 4096
 
@@ -3040,7 +3040,7 @@ PRIntervalTime _PR_UNIX_TicksPerSecond()
 }
 #endif
 
-#if defined(HAVE_CLOCK_MONOTONIC)
+#if defined(_PR_HAVE_CLOCK_MONOTONIC)
 PRIntervalTime _PR_UNIX_GetInterval2()
 {
     struct timespec time;
diff --git a/nspr/pr/src/md/windows/ntinrval.c b/nspr/pr/src/md/windows/ntinrval.c
index dab9e3f..10aca11 100644
--- a/nspr/pr/src/md/windows/ntinrval.c
+++ b/nspr/pr/src/md/windows/ntinrval.c
@@ -8,6 +8,10 @@
  *
  */
 
+/* Mozilla's build system defines this globally. */
+#ifdef WIN32_LEAN_AND_MEAN
+#undef WIN32_LEAN_AND_MEAN
+#endif
 #include "primpl.h"
 
 #ifdef WINCE
diff --git a/nspr/pr/src/md/windows/w95io.c b/nspr/pr/src/md/windows/w95io.c
index de55a8f..9bae6f8 100644
--- a/nspr/pr/src/md/windows/w95io.c
+++ b/nspr/pr/src/md/windows/w95io.c
@@ -955,9 +955,10 @@ _PR_MD_LOCKFILE(PROsfd f)
 		0l, 0l,
 		0x0l, 0xffffffffl ); 
 	if ( rv == 0 ) {
-        DWORD rc = GetLastError();
+        DWORD err = GetLastError();
+        _PR_MD_MAP_DEFAULT_ERROR(err);
         PR_LOG( _pr_io_lm, PR_LOG_ERROR,
-            ("_PR_MD_LOCKFILE() failed. Error: %d", rc ));
+            ("_PR_MD_LOCKFILE() failed. Error: %d", err ));
         rc = PR_FAILURE;
     }
 
diff --git a/nspr/pr/src/md/windows/w95thred.c b/nspr/pr/src/md/windows/w95thred.c
index 932c50c..c27d982 100644
--- a/nspr/pr/src/md/windows/w95thred.c
+++ b/nspr/pr/src/md/windows/w95thred.c
@@ -65,7 +65,7 @@ _PR_MD_INIT_THREAD(PRThread *thread)
         ** suspending).  Therefore, get a real handle from
         ** the pseudo handle via DuplicateHandle(...)
         */
-        DuplicateHandle(
+        BOOL ok = DuplicateHandle(
                 GetCurrentProcess(),     /* Process of source handle */
                 GetCurrentThread(),      /* Pseudo Handle to dup */
                 GetCurrentProcess(),     /* Process of handle */
@@ -73,6 +73,11 @@ _PR_MD_INIT_THREAD(PRThread *thread)
                 0L,                      /* access flags */
                 FALSE,                   /* Inheritable */
                 DUPLICATE_SAME_ACCESS);  /* Options */
+        if (!ok) {
+            return PR_FAILURE;
+        }
+        thread->id = GetCurrentThreadId();
+        thread->md.id = thread->id;
     }
 
     /* Create the blocking IO semaphore */
diff --git a/nspr/pr/src/misc/prenv.c b/nspr/pr/src/misc/prenv.c
index 7c9f58c..cc2e198 100644
--- a/nspr/pr/src/misc/prenv.c
+++ b/nspr/pr/src/misc/prenv.c
@@ -4,7 +4,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
+#include <stdlib.h>
 #include "primpl.h"
+#include "prmem.h"
+
+#if defined(XP_UNIX)
+#include <unistd.h>
+#if defined(DARWIN)
+#if defined(HAVE_CRT_EXTERNS_H)
+#include <crt_externs.h>
+#endif /* HAVE_CRT_EXTERNS_H */
+#else  /* DARWIN */
+PR_IMPORT_DATA(char **) environ;
+#endif /* DARWIN */
+#endif /* XP_UNIX */
+
+#if !defined(HAVE_SECURE_GETENV) && defined(HAVE___SECURE_GETENV)
+#define secure_getenv __secure_getenv
+#define HAVE_SECURE_GETENV 1
+#endif
 
 /* Lock used to lock the environment */
 #if defined(_PR_NO_PREEMPT)
@@ -52,16 +70,93 @@ PR_IMPLEMENT(char*) PR_GetEnv(const char *var)
     return ev;
 }
 
+PR_IMPLEMENT(char*) PR_GetEnvSecure(const char *var)
+{
+#ifdef HAVE_SECURE_GETENV
+  char *ev;
+
+  if (!_pr_initialized) _PR_ImplicitInitialization();
+
+  _PR_LOCK_ENV();
+  ev = secure_getenv(var);
+  _PR_UNLOCK_ENV();
+
+  return ev;
+#else
+#ifdef XP_UNIX
+  /*
+  ** Fall back to checking uids and gids.  This won't detect any other
+  ** privilege-granting mechanisms the platform may have.  This also
+  ** can't detect the case where the process already called
+  ** setuid(geteuid()) and/or setgid(getegid()).
+  */
+  if (getuid() != geteuid() || getgid() != getegid()) {
+    return NULL;
+  }
+#endif /* XP_UNIX */
+  return PR_GetEnv(var);
+#endif /* HAVE_SECURE_GETENV */
+}
+
 PR_IMPLEMENT(PRStatus) PR_SetEnv(const char *string)
 {
     PRIntn result;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
-    if ( !strchr(string, '=')) return(PR_FAILURE);
+    if (!strchr(string, '=')) return(PR_FAILURE);
+
+    _PR_LOCK_ENV();
+    result = _PR_MD_PUT_ENV((char*)string);
+    _PR_UNLOCK_ENV();
+    return result ? PR_FAILURE : PR_SUCCESS;
+}
+
+#if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))
+PR_IMPLEMENT(char **) PR_DuplicateEnvironment(void)
+{
+    char **the_environ, **result, **end, **src, **dst;
 
     _PR_LOCK_ENV();
-    result = _PR_MD_PUT_ENV(string);
+#ifdef DARWIN
+    the_environ = *(_NSGetEnviron());
+#else
+    the_environ = environ;
+#endif
+
+    for (end = the_environ; *end != NULL; end++)
+        /* empty loop body */;
+
+    result = (char **)PR_Malloc(sizeof(char *) * (end - the_environ + 1));
+    if (result != NULL) {
+        for (src = the_environ, dst = result; src != end; src++, dst++) {
+            size_t len;
+
+            len = strlen(*src) + 1;
+            *dst = PR_Malloc(len);
+            if (*dst == NULL) {
+              /* Allocation failed.  Must clean up the half-copied env. */
+              char **to_delete;
+
+              for (to_delete = result; to_delete != dst; to_delete++) {
+                PR_Free(*to_delete);
+              }
+              PR_Free(result);
+              result = NULL;
+              goto out;
+            }
+            memcpy(*dst, *src, len);
+        }
+        *dst = NULL;
+    }
+ out:
     _PR_UNLOCK_ENV();
-    return (result)? PR_FAILURE : PR_SUCCESS;
+    return result;
+}
+#else
+/* This platform doesn't support raw access to the environ block. */
+PR_IMPLEMENT(char **) PR_DuplicateEnvironment(void)
+{
+    return NULL;
 }
+#endif
diff --git a/nspr/pr/src/misc/prinit.c b/nspr/pr/src/misc/prinit.c
index 5eda4a2..43048a0 100644
--- a/nspr/pr/src/misc/prinit.c
+++ b/nspr/pr/src/misc/prinit.c
@@ -642,7 +642,10 @@ PR_IMPLEMENT(PRFileDesc *) PR_GetInheritedFD(
     while (1) {
         if ((ptr[len] == ':') && (strncmp(ptr, name, len) == 0)) {
             ptr += len + 1;
-            PR_sscanf(ptr, "%d:0x%" PR_SCNxOSFD, &fileType, &osfd);
+            if (PR_sscanf(ptr, "%d:0x%" PR_SCNxOSFD, &fileType, &osfd) != 2) {
+                PR_SetError(PR_UNKNOWN_ERROR, 0);
+                return NULL;
+            }
             switch ((PRDescType)fileType) {
                 case PR_DESC_FILE:
                     fd = PR_ImportFile(osfd);
diff --git a/nspr/pr/src/misc/prnetdb.c b/nspr/pr/src/misc/prnetdb.c
index b86248f..b2f6e43 100644
--- a/nspr/pr/src/misc/prnetdb.c
+++ b/nspr/pr/src/misc/prnetdb.c
@@ -63,8 +63,7 @@ PRLock *_pr_dnsLock = NULL;
 
 #if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \
 	|| (defined(LINUX) && defined(_REENTRANT) \
-        && !(defined(__GLIBC__) && __GLIBC__ >= 2) \
-        && !defined(ANDROID))
+        && defined(__GLIBC__) && __GLIBC__ < 2)
 #define _PR_HAVE_GETPROTO_R
 #define _PR_HAVE_GETPROTO_R_POINTER
 #endif
diff --git a/nspr/pr/src/misc/prolock.c b/nspr/pr/src/misc/prolock.c
index 312e1f4..38b7787 100644
--- a/nspr/pr/src/misc/prolock.c
+++ b/nspr/pr/src/misc/prolock.c
@@ -19,7 +19,7 @@ PR_IMPLEMENT(PROrderedLock *)
         const char *name
 )
 {
-    PR_ASSERT(!"Not implemented"); /* Not implemented yet */
+    PR_NOT_REACHED("Not implemented"); /* Not implemented yet */
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
     return NULL;
 } /*  end PR_CreateOrderedLock() */
@@ -30,7 +30,7 @@ PR_IMPLEMENT(void)
         PROrderedLock *lock 
 )
 {
-    PR_ASSERT(!"Not implemented"); /* Not implemented yet */
+    PR_NOT_REACHED("Not implemented"); /* Not implemented yet */
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
 } /*  end PR_DestroyOrderedLock() */
 
@@ -40,7 +40,7 @@ PR_IMPLEMENT(void)
         PROrderedLock *lock 
 )
 {
-    PR_ASSERT(!"Not implemented"); /* Not implemented yet */
+    PR_NOT_REACHED("Not implemented"); /* Not implemented yet */
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
 } /*  end PR_LockOrderedLock() */
 
@@ -50,7 +50,7 @@ PR_IMPLEMENT(PRStatus)
         PROrderedLock *lock 
 )
 {
-    PR_ASSERT(!"Not implemented"); /* Not implemented yet */
+    PR_NOT_REACHED("Not implemented"); /* Not implemented yet */
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
     return PR_FAILURE;
 } /*  end PR_UnlockOrderedLock() */
diff --git a/nspr/pr/src/misc/prsystem.c b/nspr/pr/src/misc/prsystem.c
index 7a25071..eba85fb 100644
--- a/nspr/pr/src/misc/prsystem.c
+++ b/nspr/pr/src/misc/prsystem.c
@@ -24,7 +24,7 @@
 
 /* BSD-derived systems use sysctl() to get the number of processors */
 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \
-    || defined(OPENBSD) || defined(DARWIN)
+    || defined(OPENBSD) || defined(DRAGONFLY) || defined(DARWIN)
 #define _PR_HAVE_SYSCTL
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -275,15 +275,24 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
     if (pageSize >= 0 && pageCount >= 0)
         bytes = (PRUint64) pageSize * pageCount;
 
-#elif defined(NETBSD) || defined(OPENBSD)
+#elif defined(NETBSD) || defined(OPENBSD) \
+    || defined(FREEBSD) || defined(DRAGONFLY)
 
     int mib[2];
     int rc;
+#ifdef HW_PHYSMEM64
     uint64_t memSize;
+#else
+    unsigned long memSize;
+#endif
     size_t len = sizeof(memSize);
 
     mib[0] = CTL_HW;
+#ifdef HW_PHYSMEM64
     mib[1] = HW_PHYSMEM64;
+#else
+    mib[1] = HW_PHYSMEM;
+#endif
     rc = sysctl(mib, 2, &memSize, &len, NULL, 0);
     if (-1 != rc)  {
         bytes = memSize;
diff --git a/nspr/pr/src/misc/prtime.c b/nspr/pr/src/misc/prtime.c
index 95d034c..6735805 100644
--- a/nspr/pr/src/misc/prtime.c
+++ b/nspr/pr/src/misc/prtime.c
@@ -1672,23 +1672,24 @@ PR_ParseTimeString(
  */
 
 PR_IMPLEMENT(PRUint32)
-PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
+PR_FormatTime(char *buf, int buflen, const char *fmt,
+              const PRExplodedTime *time)
 {
     size_t rv;
     struct tm a;
     struct tm *ap;
 
-    if (tm) {
+    if (time) {
         ap = &a;
-        a.tm_sec = tm->tm_sec;
-        a.tm_min = tm->tm_min;
-        a.tm_hour = tm->tm_hour;
-        a.tm_mday = tm->tm_mday;
-        a.tm_mon = tm->tm_month;
-        a.tm_wday = tm->tm_wday;
-        a.tm_year = tm->tm_year - 1900;
-        a.tm_yday = tm->tm_yday;
-        a.tm_isdst = tm->tm_params.tp_dst_offset ? 1 : 0;
+        a.tm_sec = time->tm_sec;
+        a.tm_min = time->tm_min;
+        a.tm_hour = time->tm_hour;
+        a.tm_mday = time->tm_mday;
+        a.tm_mon = time->tm_month;
+        a.tm_wday = time->tm_wday;
+        a.tm_year = time->tm_year - 1900;
+        a.tm_yday = time->tm_yday;
+        a.tm_isdst = time->tm_params.tp_dst_offset ? 1 : 0;
 
         /*
          * On some platforms, for example SunOS 4, struct tm has two
@@ -1699,8 +1700,8 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
         || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
         || defined(DARWIN) || defined(SYMBIAN) || defined(ANDROID)
         a.tm_zone = NULL;
-        a.tm_gmtoff = tm->tm_params.tp_gmt_offset +
-                      tm->tm_params.tp_dst_offset;
+        a.tm_gmtoff = time->tm_params.tp_gmt_offset +
+                      time->tm_params.tp_dst_offset;
 #endif
     } else {
         ap = NULL;
diff --git a/nspr/pr/src/misc/prtpool.c b/nspr/pr/src/misc/prtpool.c
index 8870a3c..0671cc1 100644
--- a/nspr/pr/src/misc/prtpool.c
+++ b/nspr/pr/src/misc/prtpool.c
@@ -281,8 +281,8 @@ PRThreadPool *tp = (PRThreadPool *) arg;
 int pollfd_cnt, pollfds_used;
 int rv;
 PRCList *qp, *nextqp;
-PRPollDesc *pollfds;
-PRJob **polljobs;
+PRPollDesc *pollfds = NULL;
+PRJob **polljobs = NULL;
 int poll_timeout;
 PRIntervalTime now;
 
diff --git a/nspr/pr/src/misc/prtrace.c b/nspr/pr/src/misc/prtrace.c
index e1b456c..058f700 100644
--- a/nspr/pr/src/misc/prtrace.c
+++ b/nspr/pr/src/misc/prtrace.c
@@ -657,14 +657,8 @@ static PRFileDesc * InitializeRecording( void )
     logLostData = 0; /* reset at entry */
     logState = LogReset;
 
-#ifdef XP_UNIX
-    if ((getuid() != geteuid()) || (getgid() != getegid())) {
-        return NULL;
-    }
-#endif /* XP_UNIX */
-
     /* Get the filename for the logfile from the environment */
-    logFileName = PR_GetEnv( "NSPR_TRACE_LOG" );
+    logFileName = PR_GetEnvSecure( "NSPR_TRACE_LOG" );
     if ( logFileName == NULL )
     {
         PR_LOG( lm, PR_LOG_ERROR,
diff --git a/nspr/pr/src/nspr.def b/nspr/pr/src/nspr.def
index 6b91e55..726979b 100644
--- a/nspr/pr/src/nspr.def
+++ b/nspr/pr/src/nspr.def
@@ -455,3 +455,10 @@ EXPORTS ;-
 ;+      global:
 		PR_SyncMemMap;
 ;+} NSPR_4.9.2;
+;+# Function PR_DuplicateEnvironment had been added in NSPR 4.10.9,
+;+# but we neglected to add it to nspr.def until NSPR 4.12
+;+NSPR_4.12 {
+;+      global:
+		PR_DuplicateEnvironment;
+		PR_GetEnvSecure;
+;+} NSPR_4.10.3;
diff --git a/nspr/pr/src/pthreads/ptio.c b/nspr/pr/src/pthreads/ptio.c
index 125f1f9..e4fe519 100644
--- a/nspr/pr/src/pthreads/ptio.c
+++ b/nspr/pr/src/pthreads/ptio.c
@@ -3765,7 +3765,7 @@ static PRInt32 _pr_poll_with_poll(
      * We use these variables to figure out how much time has
      * elapsed and how much of the timeout still remains.
      */
-    PRIntervalTime start, elapsed, remaining;
+    PRIntervalTime start = 0, elapsed, remaining;
 
     if (pt_TestAbort()) return -1;
 
@@ -4019,7 +4019,7 @@ static PRInt32 _pr_poll_with_select(
      * We use these variables to figure out how much time has
      * elapsed and how much of the timeout still remains.
      */
-    PRIntervalTime start, elapsed, remaining;
+    PRIntervalTime start = 0, elapsed, remaining;
 
     if (pt_TestAbort()) return -1;
 
@@ -4919,7 +4919,7 @@ PR_IMPLEMENT(PRInt32) PR_Select(
      * We use these variables to figure out how much time has elapsed
      * and how much of the timeout still remains.
      */
-    PRIntervalTime start, elapsed, remaining;
+    PRIntervalTime start = 0, elapsed, remaining;
 
     static PRBool unwarned = PR_TRUE;
     if (unwarned) unwarned = _PR_Obsolete( "PR_Select", "PR_Poll");
diff --git a/nspr/pr/src/pthreads/ptsynch.c b/nspr/pr/src/pthreads/ptsynch.c
index 03c5720..8663a4c 100644
--- a/nspr/pr/src/pthreads/ptsynch.c
+++ b/nspr/pr/src/pthreads/ptsynch.c
@@ -322,13 +322,21 @@ PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
     PR_ASSERT(lock != NULL);
     if (cv != NULL)
     {
-        int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
+        int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
         PR_ASSERT(0 == rv);
-        cv->lock = lock;
-        cv->notify_pending = 0;
+        if (0 == rv)
+        {
+            cv->lock = lock;
+            cv->notify_pending = 0;
 #if defined(DEBUG)
-        pt_debug.cvars_created += 1;
+            pt_debug.cvars_created += 1;
 #endif
+        }
+        else
+        {
+            PR_DELETE(cv);
+            cv = NULL;
+        }
     }
     return cv;
 }  /* PR_NewCondVar */
@@ -337,10 +345,13 @@ PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
 {
     if (0 > PR_ATOMIC_DECREMENT(&cvar->notify_pending))
     {
-        PRIntn rv = pthread_cond_destroy(&cvar->cv); PR_ASSERT(0 == rv);
+        PRIntn rv = pthread_cond_destroy(&cvar->cv);
 #if defined(DEBUG)
+        PR_ASSERT(0 == rv);
         memset(cvar, 0xaf, sizeof(PRCondVar));
         pt_debug.cvars_destroyed += 1;
+#else
+        (void)rv;
 #endif
         PR_Free(cvar);
     }
@@ -1181,9 +1192,17 @@ PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void)
     if (cv != NULL)
     {
         int rv;
-        rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
+        rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr);
         PR_ASSERT(0 == rv);
-        cv->lock = _PR_NAKED_CV_LOCK;
+        if (0 == rv)
+        {
+            cv->lock = _PR_NAKED_CV_LOCK;
+        }
+        else
+        {
+            PR_DELETE(cv);
+            cv = NULL;
+        }
     }
     return cv;
 }  /* PRP_NewNakedCondVar */
diff --git a/nspr/pr/src/pthreads/ptthread.c b/nspr/pr/src/pthreads/ptthread.c
index 4ab564a..9e12606 100644
--- a/nspr/pr/src/pthreads/ptthread.c
+++ b/nspr/pr/src/pthreads/ptthread.c
@@ -21,6 +21,10 @@
 #include <signal.h>
 #include <dlfcn.h>
 
+#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)
+#include <pthread_np.h>
+#endif
+
 #ifdef SYMBIAN
 /* In Open C sched_get_priority_min/max do not work properly, so we undefine
  * _POSIX_THREAD_PRIORITY_SCHEDULING here.
@@ -54,7 +58,7 @@ static struct _PT_Bookeeping
     pthread_key_t key;          /* thread private data key */
     PRBool keyCreated;          /* whether 'key' should be deleted */
     PRThread *first, *last;     /* list of threads we know about */
-#if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
     PRInt32 minPrio, maxPrio;   /* range of scheduling priorities */
 #endif
 } pt_book = {0};
@@ -63,7 +67,7 @@ static void _pt_thread_death(void *arg);
 static void _pt_thread_death_internal(void *arg, PRBool callDestructors);
 static void init_pthread_gc_support(void);
 
-#if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
 static PRIntn pt_PriorityMap(PRThreadPriority pri)
 {
 #ifdef NTO
@@ -325,11 +329,11 @@ static PRThread* _PR_CreateThread(
 
     if (EPERM != pt_schedpriv)
     {
-#if !defined(_PR_DCETHREADS) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if !defined(_PR_DCETHREADS) && _POSIX_THREAD_PRIORITY_SCHEDULING > 0
         struct sched_param schedule;
 #endif
 
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
         rv = pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);
         PR_ASSERT(0 == rv);
 #endif
@@ -339,7 +343,7 @@ static PRThread* _PR_CreateThread(
 #if defined(_PR_DCETHREADS)
         rv = pthread_attr_setprio(&tattr, pt_PriorityMap(priority));
         PR_ASSERT(0 == rv);
-#elif defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#elif _POSIX_THREAD_PRIORITY_SCHEDULING > 0
         rv = pthread_attr_getschedparam(&tattr, &schedule);
         PR_ASSERT(0 == rv);
         schedule.sched_priority = pt_PriorityMap(priority);
@@ -396,7 +400,7 @@ static PRThread* _PR_CreateThread(
         	scope = PR_GLOBAL_THREAD;
 			
         if (PR_GLOBAL_BOUND_THREAD == scope) {
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
     		rv = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);
 			if (rv) {
 				/*
@@ -471,7 +475,7 @@ static PRThread* _PR_CreateThread(
             PR_LOG(_pr_thread_lm, PR_LOG_MIN,
                 ("_PR_CreateThread: no thread scheduling privilege"));
             /* Try creating the thread again without setting priority. */
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
             rv = pthread_attr_setinheritsched(&tattr, PTHREAD_INHERIT_SCHED);
             PR_ASSERT(0 == rv);
 #endif
@@ -680,7 +684,7 @@ PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
 
 PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
 {
-    PRIntn rv = -1;
+    PRIntn rv;
 
     PR_ASSERT(NULL != thred);
 
@@ -692,7 +696,7 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
 #if defined(_PR_DCETHREADS)
     rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
     /* pthread_setprio returns the old priority */
-#elif defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#elif _POSIX_THREAD_PRIORITY_SCHEDULING > 0
     if (EPERM != pt_schedpriv)
     {
         int policy;
@@ -736,6 +740,8 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
                  errno));
         }
     }
+#else
+    (void)rv; /* rv is unused */
 #endif
 
     thred->priority = newPri;
@@ -921,7 +927,7 @@ void _PR_InitThreads(
     pthread_init();
 #endif
 
-#if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
 #if defined(FREEBSD)
     {
     pthread_attr_t attr;
@@ -1731,7 +1737,7 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name)
 {
     PRThread *thread;
     size_t nameLen;
-    int result;
+    int result = 0;
 
     if (!name) {
         PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
@@ -1749,8 +1755,10 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name)
         return PR_FAILURE;
     memcpy(thread->name, name, nameLen + 1);
 
-#if defined(OPENBSD) || defined(FREEBSD)
-    result = pthread_set_name_np(thread->id, name);
+#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)
+    pthread_set_name_np(thread->id, name);
+#elif defined(NETBSD)
+    result = pthread_setname_np(thread->id, "%s", (void *)name);
 #else /* not BSD */
     /*
      * On OSX, pthread_setname_np is only available in 10.6 or later, so test
diff --git a/nspr/pr/src/threads/combined/prucpu.c b/nspr/pr/src/threads/combined/prucpu.c
index 56322bb..3913dc8 100644
--- a/nspr/pr/src/threads/combined/prucpu.c
+++ b/nspr/pr/src/threads/combined/prucpu.c
@@ -124,7 +124,7 @@ static _PRCPUQueue *_PR_CreateCPUQueue(void)
     _MD_NEW_LOCK( &cpuQueue->sleepQLock );
     _MD_NEW_LOCK( &cpuQueue->miscQLock );
 
-    for (index = 0; index < PR_PRIORITY_LAST + 1; index++)
+    for (index = 0; index < PR_ARRAY_SIZE(cpuQueue->runQ); index++)
         PR_INIT_CLIST( &(cpuQueue->runQ[index]) );
     PR_INIT_CLIST( &(cpuQueue->sleepQ) );
     PR_INIT_CLIST( &(cpuQueue->pauseQ) );
diff --git a/nspr/pr/src/threads/combined/pruthr.c b/nspr/pr/src/threads/combined/pruthr.c
index 825ed89..4625ab2 100644
--- a/nspr/pr/src/threads/combined/pruthr.c
+++ b/nspr/pr/src/threads/combined/pruthr.c
@@ -73,13 +73,13 @@ void _PR_InitThreads(PRThreadType type, PRThreadPriority priority,
 #ifndef HAVE_CUSTOM_USER_THREADS
     stack = PR_NEWZAP(PRThreadStack);
 #ifdef HAVE_STACK_GROWING_UP
-    stack->stackTop = (char*) ((((long)&type) >> _pr_pageShift)
+    stack->stackTop = (char*) ((((PRWord)&type) >> _pr_pageShift)
                   << _pr_pageShift);
 #else
 #if defined(SOLARIS) || defined (UNIXWARE) && defined (USR_SVR4_THREADS)
     stack->stackTop = (char*) &thread;
 #else
-    stack->stackTop = (char*) ((((long)&type + _pr_pageSize - 1)
+    stack->stackTop = (char*) ((((PRWord)&type + _pr_pageSize - 1)
                 >> _pr_pageShift) << _pr_pageShift);
 #endif
 #endif
@@ -174,12 +174,12 @@ static void _PR_InitializeNativeStack(PRThreadStack *ts)
         ** Setup stackTop and stackBottom values.
         */
 #ifdef HAVE_STACK_GROWING_UP
-    ts->allocBase = (char*) ((((long)&ts) >> _pr_pageShift)
+    ts->allocBase = (char*) ((((PRWord)&ts) >> _pr_pageShift)
                   << _pr_pageShift);
         ts->stackBottom = ts->allocBase + ts->stackSize;
         ts->stackTop = ts->allocBase;
 #else
-        ts->allocBase = (char*) ((((long)&ts + _pr_pageSize - 1)
+        ts->allocBase = (char*) ((((PRWord)&ts + _pr_pageSize - 1)
                 >> _pr_pageShift) << _pr_pageShift);
         ts->stackTop    = ts->allocBase;
         ts->stackBottom = ts->allocBase - ts->stackSize;
diff --git a/nspr/pr/src/threads/prdump.c b/nspr/pr/src/threads/prdump.c
index 7f3e591..b40bee3 100644
--- a/nspr/pr/src/threads/prdump.c
+++ b/nspr/pr/src/threads/prdump.c
@@ -87,7 +87,7 @@ void _PR_DumpThreads(PRFileDesc *fd)
     _PR_DumpThread(fd, t);
 
     _PR_DumpPrintf(fd, "Runnable Threads:\n");
-    for (i = 0; i < 32; i++) {
+    for (i = 0; i < PR_ARRAY_SIZE(_PR_RUNQ(t->cpu)); i++) {
         DumpThreadQueue(fd, &_PR_RUNQ(t->cpu)[i]);
     }
 
diff --git a/nspr/pr/tests/Makefile.in b/nspr/pr/tests/Makefile.in
index 9ebd923..df1f1f2 100644
--- a/nspr/pr/tests/Makefile.in
+++ b/nspr/pr/tests/Makefile.in
@@ -111,6 +111,7 @@ CSRCS =             \
 	prftest.c		\
 	prftest1.c		\
 	prftest2.c		\
+	prfz.c   			\
 	primblok.c		\
 	priotest.c		\
 	provider.c		\
diff --git a/nspr/pr/tests/README.TXT b/nspr/pr/tests/README.TXT
index eaab44f..94349fa 100644
--- a/nspr/pr/tests/README.TXT
+++ b/nspr/pr/tests/README.TXT
@@ -227,6 +227,9 @@ prftest1.c
 prftest2.c
 	Obsolete. Subsumed in prftest.c
 
+prfz.c
+	Tests printf handling of (s)size_t formats
+
 priotest.c
 	Limited use. Tests NSPR thread dispatching priority.
 
diff --git a/nspr/pr/tests/env.c b/nspr/pr/tests/env.c
index e5240c4..c11588d 100644
--- a/nspr/pr/tests/env.c
+++ b/nspr/pr/tests/env.c
@@ -9,6 +9,7 @@
 **
 */
 #include "prenv.h"
+#include "prmem.h"
 #include "plgetopt.h"
 
 #include <stdio.h>
@@ -17,6 +18,7 @@
 
 PRIntn  debug = 0;
 PRIntn  verbose = 0;
+PRIntn  secure = 0;
 PRBool  failedAlready = PR_FALSE;
 
 #define  ENVNAME    "NSPR_ENVIRONMENT_TEST_VARIABLE"
@@ -42,7 +44,7 @@ int main(int argc, char **argv)
 
     {   /* Get command line options */
         PLOptStatus os;
-        PLOptState *opt = PL_CreateOptState(argc, argv, "vd");
+        PLOptState *opt = PL_CreateOptState(argc, argv, "vds");
 
 	    while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
         {
@@ -55,6 +57,15 @@ int main(int argc, char **argv)
             case 'v':  /* verbose */
                 verbose = 1;
                 break;
+            case 's':  /* secure / set[ug]id */
+                /*
+                ** To test PR_GetEnvSecure, make this executable (or a
+                ** copy of it) setuid / setgid / otherwise inherently
+                ** privileged (e.g., file capabilities) and run it
+                ** with this flag.
+                */
+                secure = 1;
+                break;
              default:
                 break;
             }
@@ -112,6 +123,109 @@ int main(int argc, char **argv)
         if (verbose) printf("env: PR_GetEnv() worked after setting it. Found: %s\n", value );
     }
 
+    if ( secure ) {
+        /*
+        ** In this case we've been run with elevated privileges, so
+        ** test that PR_GetEnvSecure *doesn't* find that env var.
+        */
+        value = PR_GetEnvSecure( ENVNAME );
+        if ( NULL != value ) {
+            if (debug) printf( "env: PR_GetEnvSecure() failed; expected NULL, found \"%s\"\n", value );
+            failedAlready = PR_TRUE;
+        } else {
+            if (verbose) printf("env: PR_GetEnvSecure() worked\n" );
+        }
+    } else {
+        /*
+        ** In this case the program is being run normally, so do the
+        ** same check for PR_GetEnvSecure as for PR_GetEnv.
+        */
+        value = PR_GetEnvSecure( ENVNAME );
+        if ( (NULL == value ) || (strcmp( value, ENVVALUE)))  {
+            if (debug) printf( "env: PR_GetEnvSecure() Failed after setting\n" );
+            failedAlready = PR_TRUE;
+        } else {
+            if (verbose) printf("env: PR_GetEnvSecure() worked after setting it. Found: %s\n", value );
+        }
+    }
+
+/* ---------------------------------------------------------------------- */
+    /* check that PR_DuplicateEnvironment() agrees with PR_GetEnv() */
+    {
+#if defined(XP_UNIX) && (!defined(DARWIN) || defined(HAVE_CRT_EXTERNS_H))
+        static const PRBool expect_failure = PR_FALSE;
+#else
+        static const PRBool expect_failure = PR_TRUE;
+#endif
+        char **i, **dupenv = PR_DuplicateEnvironment();
+
+
+        if ( NULL == dupenv ) {
+            if (expect_failure) {
+                if (verbose) printf("env: PR_DuplicateEnvironment failed, "
+                                    "as expected on this platform.\n");
+            } else {
+                if (debug) printf("env: PR_DuplicateEnvironment() failed.\n");
+                failedAlready = PR_TRUE;
+            }
+        } else {
+            unsigned found = 0;
+
+            if (expect_failure) {
+                if (debug) printf("env: PR_DuplicateEnvironment() succeeded, "
+                                  "but failure is expected on this platform.\n");
+                failedAlready = PR_TRUE;
+            } else {
+                if (verbose) printf("env: PR_DuplicateEnvironment() succeeded.\n");
+            }
+            for (i = dupenv; *i; i++) {
+                char *equals = strchr(*i, '=');
+
+                if ( equals == NULL ) {
+                    if (debug) printf("env: PR_DuplicateEnvironment() returned a string"
+                                      " with no '=': %s\n", *i);
+                    failedAlready = PR_TRUE;
+                } else {
+                    /* We own this string, so we can temporarily alter it */
+                    /* *i is the null-terminated name; equals + 1 is the value */
+                    *equals = '\0';
+
+                    if ( strcmp(*i, ENVNAME) == 0) {
+                        found++;
+                        if (verbose) printf("env: PR_DuplicateEnvironment() found " ENVNAME
+                                            " (%u so far).\n", found);
+                    }
+
+                    /* Multiple values for the same name can't happen, according to POSIX. */
+                    value = PR_GetEnv(*i);
+                    if ( value == NULL ) {
+                        if (debug) printf("env: PR_DuplicateEnvironment() returned a name"
+                                          " which PR_GetEnv() failed to find: %s\n", *i);
+                        failedAlready = PR_TRUE;
+                    } else if ( strcmp(equals + 1, value) != 0) {
+                        if (debug) printf("env: PR_DuplicateEnvironment() returned the wrong"
+                                          " value for %s: expected %s; found %s\n",
+                                          *i, value, equals + 1);
+                        failedAlready = PR_TRUE;
+                    } else {
+                        if (verbose) printf("env: PR_DuplicateEnvironment() agreed with"
+                                            " PR_GetEnv() about %s\n", *i);
+                    }
+                }
+                PR_Free(*i);
+            }
+            PR_Free(dupenv);
+
+            if (found != 1) {
+                if (debug) printf("env: PR_DuplicateEnvironment() found %u entries for " ENVNAME
+                                  " (expected 1)\n", found);
+                failedAlready = PR_TRUE;
+            } else {
+                if (verbose) printf("env: PR_DuplicateEnvironment() found 1 entry for " ENVNAME "\n");
+            }
+        }
+    }
+
 /* ---------------------------------------------------------------------- */
     /* un-set the variable, using RAW name... should not work */
     envBuf = NewBuffer( ENVBUFSIZE );
diff --git a/nspr/pr/tests/io_timeout.c b/nspr/pr/tests/io_timeout.c
index b83ff37..fa6399c 100644
--- a/nspr/pr/tests/io_timeout.c
+++ b/nspr/pr/tests/io_timeout.c
@@ -72,7 +72,7 @@ thread_main(void *_info)
 			scope_str = GLOBAL_BOUND_SCOPE_STRING;
 			break;
 		default:
-			PR_ASSERT(!"Invalid thread scope");
+			PR_NOT_REACHED("Invalid thread scope");
 			break;
 	}
 	printf("thread id %d, scope %s\n", info->id, scope_str);
diff --git a/nspr/pr/tests/multiwait.c b/nspr/pr/tests/multiwait.c
index a24342a..61b08df 100644
--- a/nspr/pr/tests/multiwait.c
+++ b/nspr/pr/tests/multiwait.c
@@ -506,7 +506,7 @@ static void PR_CALLBACK ServerThread(void *arg)
         {
             if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) break;
             PL_PrintError("Accept failed");
-            MW_ASSERT(!"Accept failed");
+            MW_ASSERT(PR_FALSE && "Accept failed");
         }
         else
         {
diff --git a/nspr/pr/tests/nblayer.c b/nspr/pr/tests/nblayer.c
index 553db6b..0d9aec4 100644
--- a/nspr/pr/tests/nblayer.c
+++ b/nspr/pr/tests/nblayer.c
@@ -104,7 +104,7 @@ static void PR_CALLBACK Client(void *arg)
             ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
             if ((1 != ready)  /* if not 1, then we're dead */
             || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                { PR_ASSERT(!"Whoa!"); break; }
+                { PR_NOT_REACHED("Whoa!"); break; }
             if (verbosity > quiet)
                 PR_fprintf(
                     logFile, "Client connect 'in progress' [0x%x]\n",
@@ -143,7 +143,7 @@ static void PR_CALLBACK Client(void *arg)
                 ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
                 if ((1 != ready)  /* if not 1, then we're dead */
                 || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                    { PR_ASSERT(!"Whoa!"); break; }
+                    { PR_NOT_REACHED("Whoa!"); break; }
             }
             else break;
         } while (bytes_sent < sizeof(buffer));
@@ -171,7 +171,7 @@ static void PR_CALLBACK Client(void *arg)
                 ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
                 if ((1 != ready)  /* if not 1, then we're dead */
                 || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                    { PR_ASSERT(!"Whoa!"); break; }
+                    { PR_NOT_REACHED("Whoa!"); break; }
             }
             else break;
         } while (bytes_read < bytes_sent);
@@ -213,7 +213,7 @@ static void PR_CALLBACK Server(void *arg)
             ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
             if ((1 != ready)  /* if not 1, then we're dead */
             || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                { PR_ASSERT(!"Whoa!"); break; }
+                { PR_NOT_REACHED("Whoa!"); break; }
         }
     } while (NULL == service);
     PR_ASSERT(NULL != service);
@@ -244,7 +244,7 @@ static void PR_CALLBACK Server(void *arg)
                 ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
                 if ((1 != ready)  /* if not 1, then we're dead */
                 || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                    { PR_ASSERT(!"Whoa!"); break; }
+                    { PR_NOT_REACHED("Whoa!"); break; }
             }
             else break;
         } while (bytes_read < sizeof(buffer));
@@ -273,7 +273,7 @@ static void PR_CALLBACK Server(void *arg)
                     ready = PR_Poll(&polldesc, 1, PR_INTERVAL_NO_TIMEOUT);
                     if ((1 != ready)  /* if not 1, then we're dead */
                     || (0 == (polldesc.in_flags & polldesc.out_flags)))
-                        { PR_ASSERT(!"Whoa!"); break; }
+                        { PR_NOT_REACHED("Whoa!"); break; }
                 }
                 else break;
             } while (bytes_sent < bytes_read);
@@ -329,7 +329,7 @@ static PRInt16 PR_CALLBACK MyPoll(
             default: break;
         }
     }
-    else PR_ASSERT(!"How'd I get here?");
+    else PR_NOT_REACHED("How'd I get here?");
     new_flags = (fd->lower->methods->poll)(fd->lower, my_flags, out_flags);
     if (verbosity > chatty)
         PR_fprintf(
diff --git a/nspr/pr/tests/prfz.c b/nspr/pr/tests/prfz.c
new file mode 100644
index 0000000..0c5a432
--- /dev/null
+++ b/nspr/pr/tests/prfz.c
@@ -0,0 +1,84 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * This is a simple test of the PR_fprintf() function for size_t formats.
+ */
+
+#include "prprf.h"
+#include <sys/types.h>
+#include <limits.h>
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+    char buffer[128];
+
+    size_t  unsigned_small  = 266;
+#ifdef XP_UNIX
+    ssize_t signed_small_p  = 943;
+    ssize_t signed_small_n  = -1;
+#endif
+    size_t  unsigned_max    = SIZE_MAX;
+    size_t  unsigned_min    = 0;
+#ifdef XP_UNIX
+    ssize_t signed_max      = SSIZE_MAX;
+#endif
+
+    printf("Test: unsigned small '%%zu' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zu", unsigned_small);
+    if (strncmp(buffer, "266", sizeof(buffer)) != 0) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+
+#ifdef XP_UNIX
+    printf("Test: signed small positive '%%zd' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zd", signed_small_p);
+    if (strncmp(buffer, "943", sizeof(buffer)) != 0) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+
+    printf("Test: signed small negative '%%zd' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zd", signed_small_n);
+    if (strncmp(buffer, "-1", sizeof(buffer)) != 0) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+#endif
+
+    printf("Test: 0 '%%zu' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zu", unsigned_min);
+    if (strncmp(buffer, "0", sizeof(buffer)) != 0) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+
+    printf("Test: SIZE_MAX '%%zx' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zx", unsigned_max);
+    if (strspn(buffer, "f") != sizeof(size_t) * 2) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+
+#ifdef XP_UNIX
+    printf("Test: SSIZE_MAX '%%zx' : ");
+    PR_snprintf(buffer, sizeof(buffer), "%zx", signed_max);
+    if (*buffer != '7' ||
+        strspn(buffer + 1, "f") != sizeof(ssize_t) * 2 - 1) {
+        printf("Failed, got '%s'\n", buffer);
+        return -1;
+    }
+    printf("OK\n");
+#endif
+
+    return 0;
+}
diff --git a/nspr/pr/tests/priotest.c b/nspr/pr/tests/priotest.c
index ca7897e..577d553 100644
--- a/nspr/pr/tests/priotest.c
+++ b/nspr/pr/tests/priotest.c
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
 
     PR_ProcessExit((failed) ? 1 : 0);
 
-	PR_ASSERT(!"You can't get here -- but you did!");
+	PR_NOT_REACHED("You can't get here -- but you did!");
 	return 1;  /* or here */
 
 }  /* main */
diff --git a/nspr/pr/tests/runtests.pl b/nspr/pr/tests/runtests.pl
index 3a164b1..5dbc649 100755
--- a/nspr/pr/tests/runtests.pl
+++ b/nspr/pr/tests/runtests.pl
@@ -310,6 +310,7 @@ $prog = shift;  # Program to test
 "poll_to",
 "pollable",
 "prftest",
+"prfz",
 "primblok",
 "provider",
 "prpollml",
diff --git a/nspr/pr/tests/runtests.sh b/nspr/pr/tests/runtests.sh
index 535b93a..760f032 100755
--- a/nspr/pr/tests/runtests.sh
+++ b/nspr/pr/tests/runtests.sh
@@ -140,6 +140,7 @@ poll_nm
 poll_to
 pollable
 prftest
+prfz
 primblok
 provider
 prpollml
diff --git a/nspr/pr/tests/rwlockrank.c b/nspr/pr/tests/rwlockrank.c
index 8d128f3..5872fa1 100644
--- a/nspr/pr/tests/rwlockrank.c
+++ b/nspr/pr/tests/rwlockrank.c
@@ -22,7 +22,7 @@ static void rwtest(void *args)
     PR_RWLock_Rlock(rwlock1);
     PR_RWLock_Unlock(rwlock1);
 
-    // Test correct lock rank.
+    /* Test correct lock rank. */
     PR_RWLock_Rlock(rwlock1);
     PR_RWLock_Rlock(rwlock2);
     PR_RWLock_Unlock(rwlock2);
@@ -41,7 +41,7 @@ static void rwtest(void *args)
     PR_RWLock_Unlock(rwlock1);
 
 #if 0
-    // Test incorrect lock rank.
+    /* Test incorrect lock rank. */
     PR_RWLock_Rlock(rwlock2);
     PR_RWLock_Rlock(rwlock1);
     PR_RWLock_Unlock(rwlock1);
diff --git a/nspr/pr/tests/server_test.c b/nspr/pr/tests/server_test.c
index 5c608cd..b794a7f 100644
--- a/nspr/pr/tests/server_test.c
+++ b/nspr/pr/tests/server_test.c
@@ -37,6 +37,7 @@
 #define PASS 0
 #define FAIL 1
 static int debug_mode = 0;
+static int failed_already = 0;
 
 static int _iterations = 1000;
 static int _clients = 1;
@@ -90,6 +91,7 @@ static void Test_Result (int result)
 			break;
 		case FAIL:
 			printf ("FAIL\n");
+			failed_already = 1;
 			break;
 		default:
 			break;
@@ -246,21 +248,32 @@ PRFileDesc *
 ServerSetup(void)
 {
     PRFileDesc *listenSocket;
+    PRSocketOptionData sockOpt;
     PRNetAddr serverAddr;
     PRThread *WorkerThread;
 
-    if ( (listenSocket = PR_NewTCPSocket()) == NULL) {
+    if ((listenSocket = PR_NewTCPSocket()) == NULL) {
         if (debug_mode) printf("\tServer error creating listen socket\n");
 		else Test_Result(FAIL);
         return NULL;
     }
 
+    sockOpt.option = PR_SockOpt_Reuseaddr;
+    sockOpt.value.reuse_addr = PR_TRUE;
+    if (PR_SetSocketOption(listenSocket, &sockOpt) != PR_SUCCESS) {
+        if (debug_mode) printf("\tServer error setting socket option: OS error %d\n",
+                PR_GetOSError());
+        else Test_Result(FAIL);
+        PR_Close(listenSocket);
+        return NULL;
+    }
+
     memset(&serverAddr, 0, sizeof(PRNetAddr));
     serverAddr.inet.family = PR_AF_INET;
     serverAddr.inet.port = PR_htons(PORT);
     serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);
 
-    if ( PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {
+    if (PR_Bind(listenSocket, &serverAddr) != PR_SUCCESS) {
         if (debug_mode) printf("\tServer error binding to server address: OS error %d\n",
                 PR_GetOSError());
 		else Test_Result(FAIL);
@@ -268,7 +281,7 @@ ServerSetup(void)
         return NULL;
     }
 
-    if ( PR_Listen(listenSocket, 128) == PR_FAILURE) {
+    if (PR_Listen(listenSocket, 128) != PR_SUCCESS) {
         if (debug_mode) printf("\tServer error listening to server socket\n");
 		else Test_Result(FAIL);
         PR_Close(listenSocket);
@@ -548,7 +561,7 @@ int main(int argc, char **argv)
 	Usage: test_name -d
 	*/
 	PLOptStatus os;
-	PLOptState *opt = PL_CreateOptState(argc, argv, "d:");
+	PLOptState *opt = PL_CreateOptState(argc, argv, "d");
 	while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
     {
 		if (PL_OPT_BAD == os) continue;
@@ -606,5 +619,5 @@ int main(int argc, char **argv)
 
     PR_Cleanup();
 
-    return 0;
+    return failed_already;
 }
diff --git a/nspr/pr/tests/socket.c b/nspr/pr/tests/socket.c
index 3544ba5..5ee2b78 100644
--- a/nspr/pr/tests/socket.c
+++ b/nspr/pr/tests/socket.c
@@ -328,7 +328,7 @@ PRInt32 native_thread = 0;
 			native_thread = 1;
 			break;
 		default:
-			PR_ASSERT(!"Invalid scope");
+			PR_NOT_REACHED("Invalid scope");
 			break;
 	}
 	if (native_thread) {
diff --git a/nspr/pr/tests/testfile.c b/nspr/pr/tests/testfile.c
index b5f07fa..2365987 100644
--- a/nspr/pr/tests/testfile.c
+++ b/nspr/pr/tests/testfile.c
@@ -120,7 +120,7 @@ PRInt32 native_thread = 0;
 			native_thread = 1;
 			break;
 		default:
-			PR_ASSERT(!"Invalid scope");
+			PR_NOT_REACHED("Invalid scope");
 			break;
 	}
 	if (native_thread) {
diff --git a/nspr/pr/tests/vercheck.c b/nspr/pr/tests/vercheck.c
index f9f183b..b19b579 100644
--- a/nspr/pr/tests/vercheck.c
+++ b/nspr/pr/tests/vercheck.c
@@ -20,10 +20,9 @@
 #include <stdlib.h>
 
 /*
- * This release (4.10.7) is backward compatible with the
+ * This release (4.10.10) is backward compatible with the
  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
- * 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4,
- * 4.10.5, and 4.10.6 releases.
+ * 4.8.x, 4.9.x, 4.10.x and 4.11.X releases.
  * It, of course, is compatible with itself.
  */
 static char *compatible_version[] = {
@@ -39,7 +38,8 @@ static char *compatible_version[] = {
     "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5",
     "4.9.6",
     "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
-    "4.10.5", "4.10.6",
+    "4.10.5", "4.10.6", "4.10.7", "4.10.8", "4.10.9",
+    "4.10.10", "4.11",
     PR_VERSION
 };
 
@@ -55,8 +55,8 @@ static char *incompatible_version[] = {
     "3.0", "3.0.1",
     "3.1", "3.1.1", "3.1.2", "3.1.3",
     "3.5", "3.5.1",
-    "4.10.8",
-    "4.11", "4.11.1",
+    "4.11.1",
+    "4.12.1",
     "10.0", "11.1", "12.14.20"
 };
 
diff --git a/debian/changelog b/debian/changelog
index 04f4284..8bc4173 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+nspr (2:4.12-2~bpo8) jessie-backports; urgency=medium
+
+  * Backport to jessie and enable internal test suite
+
+ -- Guido Günther <agx@sigxcpu.org>  Fri, 20 May 2016 17:37:53 +0200
+
 nspr (2:4.12-2) unstable; urgency=medium
 
   * debian/rules, debian/libnspr4.triggers. Replace makeshlibs scripts that
diff --git a/debian/patches/Drop-fdcach-until-debugged.patch b/debian/patches/Drop-fdcach-until-debugged.patch
new file mode 100644
index 0000000..669dc25
--- /dev/null
+++ b/debian/patches/Drop-fdcach-until-debugged.patch
@@ -0,0 +1,21 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Sat, 2 Jan 2016 18:55:51 +0100
+Subject: Skip fdcach test until debugged
+
+since this fails reliably in pbuilder and outside
+---
+ nspr/pr/tests/runtests.sh | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/nspr/pr/tests/runtests.sh b/nspr/pr/tests/runtests.sh
+index 760f032..c1cf0e3 100755
+--- a/nspr/pr/tests/runtests.sh
++++ b/nspr/pr/tests/runtests.sh
+@@ -89,7 +89,6 @@ dlltest
+ dtoa
+ errcodes
+ exit
+-fdcach
+ fileio
+ foreign
+ formattm
diff --git a/debian/patches/Fix-vercheck-test.patch b/debian/patches/Fix-vercheck-test.patch
new file mode 100644
index 0000000..b7b24d3
--- /dev/null
+++ b/debian/patches/Fix-vercheck-test.patch
@@ -0,0 +1,30 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Fri, 20 May 2016 17:17:29 +0200
+Subject: Fix vercheck test
+
+4.12 must be compatible with 4.11.1
+---
+ nspr/pr/tests/vercheck.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/nspr/pr/tests/vercheck.c b/nspr/pr/tests/vercheck.c
+index b19b579..582c1a6 100644
+--- a/nspr/pr/tests/vercheck.c
++++ b/nspr/pr/tests/vercheck.c
+@@ -39,7 +39,7 @@ static char *compatible_version[] = {
+     "4.9.6",
+     "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
+     "4.10.5", "4.10.6", "4.10.7", "4.10.8", "4.10.9",
+-    "4.10.10", "4.11",
++    "4.10.10", "4.11", "4.11.1",
+     PR_VERSION
+ };
+ 
+@@ -55,7 +55,6 @@ static char *incompatible_version[] = {
+     "3.0", "3.0.1",
+     "3.1", "3.1.1", "3.1.2", "3.1.3",
+     "3.5", "3.5.1",
+-    "4.11.1",
+     "4.12.1",
+     "10.0", "11.1", "12.14.20"
+ };
diff --git a/debian/patches/Use-localhost-for-gethost-test.patch b/debian/patches/Use-localhost-for-gethost-test.patch
new file mode 100644
index 0000000..007fb98
--- /dev/null
+++ b/debian/patches/Use-localhost-for-gethost-test.patch
@@ -0,0 +1,22 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Thu, 31 Dec 2015 14:00:05 +0100
+Subject: Use localhost for gethost test
+
+otherwise we fail without a network connection
+---
+ nspr/pr/tests/gethost.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nspr/pr/tests/gethost.c b/nspr/pr/tests/gethost.c
+index 779bce4..0be4eb6 100644
+--- a/nspr/pr/tests/gethost.c
++++ b/nspr/pr/tests/gethost.c
+@@ -18,7 +18,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+-#define DEFAULT_HOST_NAME "mcom.com"
++#define DEFAULT_HOST_NAME "127.0.0.1"
+ 
+ static void Help(void)
+ {
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..c6d7746
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+Use-localhost-for-gethost-test.patch
+Drop-fdcach-until-debugged.patch
+Fix-vercheck-test.patch
diff --git a/debian/rules b/debian/rules
index cde731b..46766b0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -73,6 +73,13 @@ override_dh_strip:
 override_dh_makeshlibs:
 	dh_makeshlibs -a -- -c4
 
+override_dh_auto_test:
+	$(MAKE) -C nspr/pr/tests
+	$(MAKE) -C nspr/lib/tests
+	cd nspr/pr/tests && ./runtests.sh
+	cd nspr/lib/tests && ./base64t
+	cd nspr/lib/tests && ./string
+
 ifneq (,$(DEB_HOST_MULTIARCH))
 override_dh_gencontrol:
 	dh_gencontrol -- -Vmisc:Multi-Arch=same
Title: nspr: 4.10.7 to 4.12 compatibility report

API compatibility report for the nspr library between 4.10.7 and 4.12 versions on x86_64


Binary
Compatibility
Source
Compatibility

Test Info


Library Namenspr
Version #14.10.7
Version #24.12
CPU Typex86_64
GCC Version5.3.1
SubjectBinary Compatibility

Test Results


Total Header Files55
Total Shared Libraries3
Total Symbols / Types456 / 311
VerdictCompatible

Problem Summary


SeverityCount
Added Symbols-2
Removed SymbolsHigh0
Problems with
Data Types
High0
Medium0
Low0
Problems with
Symbols
High0
Medium0
Low2
Problems with
Constants
Low0

Added Symbols (2)


prenv.h, libnspr4.so
PR_DuplicateEnvironment ( )
PR_GetEnvSecure char const* var )

to the top

Problems with Symbols, Low Severity (2)


prtime.h, libnspr4.so
[+] PR_FormatTime char* buf, int buflen, char const* fmt, PRExplodedTime const* tm ) (1)
[+] PR_FormatTimeUSEnglish char* buf, PRUint32 bufSize, char const* format, PRExplodedTime const* tm ) (1)

to the top

Header Files (55)


nspr.h
plarena.h
plarenas.h
plbase64.h
plerror.h
plgetopt.h
plhash.h
plstr.h
pprio.h
pprthred.h
pralarm.h
pratom.h
prbit.h
prclist.h
prcmon.h
prcountr.h
prcpucfg.h
prcvar.h
prdtoa.h
prenv.h
prerr.h
prerror.h
prinet.h
prinit.h
prinrval.h
prio.h
pripcsem.h
prlink.h
prlock.h
prlog.h
prlong.h
prmem.h
prmon.h
prmwait.h
prnetdb.h
probslet.h
prolock.h
protypes.h
prpdce.h
prprf.h
prpriv.h
prproces.h
prrng.h
prrwlock.h
prsem.h
prshm.h
prshma.h
prsystem.h
prthread.h
prtime.h
prtpool.h
prtrace.h
prtypes.h
prvrsion.h
prwin16.h

to the top

Shared Libraries (3)


libnspr4.so
libplc4.so
libplds4.so

to the top



Test Info


Library Namenspr
Version #14.10.7
Version #24.12
CPU Typex86_64
GCC Version5.3.1
SubjectSource Compatibility

Test Results


Total Header Files55
Total Shared Libraries3
Total Symbols / Types469 / 313
VerdictCompatible

Problem Summary


SeverityCount
Added Symbols-2
Removed SymbolsHigh0
Problems with
Data Types
High0
Medium0
Low0
Problems with
Symbols
High0
Medium0
Low0
Problems with
Constants
Low3
Other Changes
in Symbols
-2

Added Symbols (2)


prenv.h
PR_DuplicateEnvironment ( )
PR_GetEnvSecure char const* var )

to the top

Problems with Constants, Low Severity (3)


prinit.h
[+] PR_VERSION
[+] PR_VMINOR
[+] PR_VPATCH

to the top

Other Changes in Symbols (2)


prtime.h
[+] PR_FormatTime char* buf, int buflen, char const* fmt, PRExplodedTime const* tm ) (1)
[+] PR_FormatTimeUSEnglish char* buf, PRUint32 bufSize, char const* format, PRExplodedTime const* tm ) (1)

to the top

Header Files (55)


nspr.h
plarena.h
plarenas.h
plbase64.h
plerror.h
plgetopt.h
plhash.h
plstr.h
pprio.h
pprthred.h
pralarm.h
pratom.h
prbit.h
prclist.h
prcmon.h
prcountr.h
prcpucfg.h
prcvar.h
prdtoa.h
prenv.h
prerr.h
prerror.h
prinet.h
prinit.h
prinrval.h
prio.h
pripcsem.h
prlink.h
prlock.h
prlog.h
prlong.h
prmem.h
prmon.h
prmwait.h
prnetdb.h
probslet.h
prolock.h
protypes.h
prpdce.h
prprf.h
prpriv.h
prproces.h
prrng.h
prrwlock.h
prsem.h
prshm.h
prshma.h
prsystem.h
prthread.h
prtime.h
prtpool.h
prtrace.h
prtypes.h
prvrsion.h
prwin16.h

to the top

Shared Libraries (3)


libnspr4.so
libplc4.so
libplds4.so

to the top





Title: nss: 3.17.2 to 3.23 compatibility report

API compatibility report for the nss library between 3.17.2 and 3.23 versions on x86_64


Binary
Compatibility
Source
Compatibility

Test Info


Library Namenss
Version #13.17.2
Version #23.23
CPU Typex86_64
GCC Version5.3.1
SubjectBinary Compatibility

Test Results


Total Header Files95
Total Shared Libraries8
Total Symbols / Types1258 / 603
VerdictIncompatible
(0.1%)

Problem Summary


SeverityCount
Added Symbols-21
Removed SymbolsHigh0
Problems with
Data Types
High0
Medium0
Low0
Problems with
Symbols
High0
Medium3
Low20
Problems with
Constants
Low1
Other Changes
in Constants
-28

Added Symbols (21)


cert.h, libnss3.so
CERT_GetImposedNameConstraints ( SECItem const* derSubject, SECItem* extensions ) @@ NSS_3.19

certdb.h, libnss3.so
SEC_CheckCrlTimes CERTCrl* crl, PRTime t ) @@ NSS_3.18
SEC_GetCrlTimes CERTCrl* crl, PRTime* notBefore, PRTime* notAfter ) @@ NSS_3.18

keyhi.h, libnss3.so
SECKEY_BigIntegerBitLength SECItem const* number ) @@ NSS_3.19.1

nss.h, libnss3.so
NSS_OptionGet PRInt32 which, PRInt32* value ) @@ NSS_3.21
NSS_OptionSet PRInt32 which, PRInt32 value ) @@ NSS_3.21

p12.h, libsmime3.so
SEC_PKCS12DecoderRenameCertNicknames ( SEC_PKCS12DecoderContext* p12dcx, SEC_PKCS12NicknameRenameCallback nicknameCb, void* arg ) @@ NSS_3.18

pk11pub.h, libnss3.so
__PK11_SetCertificateNickname ( CERTCertificate* cert, char const* nickname ) @@ NSS_3.18
PK11_SignWithMechanism ( SECKEYPrivateKey* key, CK_MECHANISM_TYPE mechanism, SECItem const* param, SECItem* sig, SECItem const* hash ) @@ NSS_3.22
PK11_VerifyWithMechanism ( SECKEYPublicKey* key, CK_MECHANISM_TYPE mechanism, SECItem const* param, SECItem const* sig, SECItem const* hash, void* wincx ) @@ NSS_3.22

secmod.h, libnss3.so
SECMOD_CreateModuleEx char const* lib, char const* name, char const* param, char const* nss, char const* config ) @@ NSS_3.21

ssl.h, libssl3.so
SSL_DHEGroupPrefSet PRFileDesc* fd, enum SSLDHEGroupType* groups, PRUint16 num_groups ) @@ NSS_3.20
SSL_EnableWeakDHEPrimeGroup PRFileDesc* fd, PRBool enabled ) @@ NSS_3.20
SSL_GetPreliminaryChannelInfo PRFileDesc* fd, SSLPreliminaryChannelInfo* info, PRUintn len ) @@ NSS_3.21
SSL_PeerSignedCertTimestamps PRFileDesc* fd ) @@ NSS_3.22
SSL_SetDowngradeCheckVersion PRFileDesc* fd, PRUint16 version ) @@ NSS_3.23
SSL_SetSignedCertTimestamps PRFileDesc* fd, SECItem const* scts, enum SSLKEAType kea ) @@ NSS_3.22
SSL_SignatureMaxCount ( ) @@ NSS_3.21
SSL_SignaturePrefGet PRFileDesc* fd, SSLSignatureAndHashAlg* algorithms, unsigned int* count, unsigned int maxCount ) @@ NSS_3.21
SSL_SignaturePrefSet PRFileDesc* fd, SSLSignatureAndHashAlg const* algorithms, unsigned int count ) @@ NSS_3.21

utilpars.h, libnssutil3.so
NSSUTIL_ArgParseModuleSpecEx ( char const* modulespec, char** lib, char** mod, char** parameters, char** nss, char** config ) @@ NSSUTIL_3.21

to the top

Problems with Symbols, Medium Severity (3)


ssl.h, libssl3.so
[+] SSL_ImplementedCiphers [data] @@ NSS_3.2 (1)

utilpars.h, libnssutil3.so
[+] NSSUTIL_ArgSkipParameter char* string ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgStrip char* c ) @@ NSSUTIL_3.14 (1)

to the top

Problems with Symbols, Low Severity (20)


utilpars.h, libnssutil3.so
[+] _NSSUTIL_GetSecmodName char* param, enum NSSDBType* dbType, char** appName, char** filename, PRBool* rw ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgDecodeNumber char* num ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgFetchValue char* string, int* pcount ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgGetLabel char* inString, int* next ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgGetParamValue char* paramName, char* parameters ) @@ NSSUTIL_3.14 (2)
[+] NSSUTIL_ArgHasFlag char* label, char* flag, char* parameters ) @@ NSSUTIL_3.14 (3)
[+] NSSUTIL_ArgParseCipherFlags ( unsigned long* newCiphers, char* cipherList ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgParseModuleSpec ( char* modulespec, char** lib, char** mod, char** parameters, char** nss ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgParseSlotFlags char* label, char* params ) @@ NSSUTIL_3.14 (2)
[+] NSSUTIL_ArgParseSlotInfo ( PLArenaPool* arena, char* slotParams, int* retCount ) @@ NSSUTIL_3.14 (1)
[+] NSSUTIL_ArgReadLong char* label, char* params, long defValue, PRBool* isdefault ) @@ NSSUTIL_3.14 (2)
[+] NSSUTIL_ArgSkipParameter char* string ) @@ NSSUTIL_3.14 (2)
[+] NSSUTIL_ArgStrip char* c ) @@ NSSUTIL_3.14 (2)

to the top

Problems with Constants, Low Severity (1)


sslt.h
[+] SSL_MAX_EXTENSIONS

to the top

Other Changes in Constants (28)


nss.h
[+] NSS_DH_MIN_KEY_SIZE
[+] NSS_DSA_MIN_KEY_SIZE
[+] NSS_RSA_MIN_KEY_SIZE

pkcs11t.h
[+] CKM_TLS12_KEY_AND_MAC_DERIVE
[+] CKM_TLS12_KEY_SAFE_DERIVE
[+] CKM_TLS12_MASTER_KEY_DERIVE
[+] CKM_TLS12_MASTER_KEY_DERIVE_DH
[+] CKM_TLS_KDF
[+] CKM_TLS_MAC
[+] CKP_PKCS5_PBKD2_HMAC_GOSTR3411
[+] CKP_PKCS5_PBKD2_HMAC_SHA224
[+] CKP_PKCS5_PBKD2_HMAC_SHA256
[+] CKP_PKCS5_PBKD2_HMAC_SHA384
[+] CKP_PKCS5_PBKD2_HMAC_SHA512
[+] CKP_PKCS5_PBKD2_HMAC_SHA512_224
[+] CKP_PKCS5_PBKD2_HMAC_SHA512_256

secoidt.h
[+] NSS_USE_ALG_IN_SSL
[+] NSS_USE_ALG_IN_SSL_KX
[+] NSS_USE_POLICY_IN_SSL

ssl.h
[+] SSL_ENABLE_EXTENDED_MASTER_SECRET
[+] SSL_ENABLE_SERVER_DHE
[+] SSL_ENABLE_SIGNED_CERT_TIMESTAMPS

sslproto.h
[+] TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
[+] TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
[+] TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
[+] TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
[+] TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256

sslt.h
[+] ssl_preinfo_cipher_suite

to the top

Header Files (95)


base64.h
blapit.h
cert.h
certdb.h
certt.h
ciferfam.h
cmmf.h
cmmft.h
cms.h
cmsreclist.h
cmst.h
crmf.h
crmft.h
cryptohi.h
cryptoht.h
ecl-exp.h
hasht.h
jar-ds.h
jar.h
jarfile.h
key.h
keyhi.h
keyt.h
keythi.h
nss.h
nssb64.h
nssb64t.h
nssbase.h
nssbaset.h
nssckbi.h
nssckepv.h
nssckft.h
nssckfw.h
nssckfwc.h
nssckfwt.h
nssckg.h
nssckmdt.h
nssckt.h
nssilckt.h
nssilock.h
nsslocks.h
nsslowhash.h
nssrwlk.h
nssrwlkt.h
nssutil.h
ocsp.h
ocspt.h
p12.h
p12plcy.h
p12t.h
pk11func.h
pk11pqg.h
pk11priv.h
pk11pub.h
pk11sdr.h
pkcs11.h
pkcs11f.h
pkcs11n.h
pkcs11p.h
pkcs11t.h
pkcs11u.h
pkcs12.h
pkcs12t.h
pkcs1sig.h
pkcs7t.h
portreg.h
preenc.h
secasn1.h
secasn1t.h
seccomon.h
secder.h
secdert.h
secdig.h
secdigt.h
secerr.h
sechash.h
secitem.h
secmime.h
secmod.h
secmodt.h
secoid.h
secoidt.h
secpkcs5.h
secpkcs7.h
secport.h
shsign.h
smime.h
ssl.h
sslerr.h
sslproto.h
sslt.h
utilmodt.h
utilpars.h
utilparst.h
utilrename.h

to the top

Shared Libraries (8)


libfreebl3.so
libnss3.so
libnssckbi.so
libnssdbm3.so
libnssutil3.so
libsmime3.so
libsoftokn3.so
libssl3.so

to the top



Test Info


Library Namenss
Version #13.17.2
Version #23.23
CPU Typex86_64
GCC Version5.3.1
SubjectSource Compatibility

Test Results


Total Header Files95
Total Shared Libraries8
Total Symbols / Types2206 / 1039
VerdictIncompatible
(0.1%)

Problem Summary


SeverityCount
Added Symbols-22
Removed SymbolsHigh2
Problems with
Data Types
High0
Medium0
Low0
Problems with
Symbols
High0
Medium2
Low0
Problems with
Constants
Low9
Other Changes
in Constants
-39

Added Symbols (22)


cert.h
CERT_GetImposedNameConstraints ( SECItem const* derSubject, SECItem* extensions )

certdb.h
SEC_GetCrlTimes CERTCrl* crl, PRTime* notBefore, PRTime* notAfter )

keyhi.h
SECKEY_BigIntegerBitLength SECItem const* number )
SECKEY_GetECCOid SECKEYECParams const* params )

nss.h
NSS_OptionGet PRInt32 which, PRInt32* value )
NSS_OptionSet PRInt32 which, PRInt32 value )

p12.h
SEC_PKCS12DecoderRenameCertNicknames ( SEC_PKCS12DecoderContext* p12dcx, SEC_PKCS12NicknameRenameCallback nicknameCb, void* arg )

pk11pub.h
__PK11_SetCertificateNickname ( CERTCertificate* cert, char const* nickname )
PK11_SignWithMechanism ( SECKEYPrivateKey* key, CK_MECHANISM_TYPE mechanism, SECItem const* param, SECItem* sig, SECItem const* hash )
PK11_VerifyWithMechanism ( SECKEYPublicKey* key, CK_MECHANISM_TYPE mechanism, SECItem const* param, SECItem const* sig, SECItem const* hash, void* wincx )

secmod.h
SECMOD_CreateModuleEx char const* lib, char const* name, char const* param, char const* nss, char const* config )

ssl.h
SSL_DHEGroupPrefSet PRFileDesc* fd, enum SSLDHEGroupType* groups, PRUint16 num_groups )
SSL_EnableWeakDHEPrimeGroup PRFileDesc* fd, PRBool enabled )
SSL_GetPreliminaryChannelInfo PRFileDesc* fd, SSLPreliminaryChannelInfo* info, PRUintn len )
SSL_PeerSignedCertTimestamps PRFileDesc* fd )
SSL_SetDowngradeCheckVersion PRFileDesc* fd, PRUint16 version )
SSL_SetSignedCertTimestamps PRFileDesc* fd, SECItem const* scts, enum SSLKEAType kea )
SSL_SignatureMaxCount ( )
SSL_SignaturePrefGet PRFileDesc* fd, SSLSignatureAndHashAlg* algorithms, unsigned int* count, unsigned int maxCount )
SSL_SignaturePrefSet PRFileDesc* fd, SSLSignatureAndHashAlg const* algorithms, unsigned int count )

utilpars.h
NSSUTIL_ArgParseModuleSpecEx ( char const* modulespec, char** lib, char** mod, char** parameters, char** nss, char** config )
NSSUTIL_MkModuleSpecEx char* dllName, char* commonName, char* parameters, char* NSS, char* config )

to the top

Removed Symbols (2)


cert.h
CERT_FindCertURLExtension ( CERTCertificate* cert, int tag, int catag )
CERT_FindIssuerCertExtension ( CERTCertificate* cert, int tag, SECItem* value )

to the top

Problems with Symbols, Medium Severity (2)


utilpars.h
[+] NSSUTIL_ArgSkipParameter char* string ) (1)
[+] NSSUTIL_ArgStrip char* c ) (1)

to the top

Problems with Constants, Low Severity (9)


nss.h
[+] NSS_VERSION
[+] NSS_VMINOR
[+] NSS_VPATCH

nssckbi.h
[+] NSS_BUILTINS_LIBRARY_VERSION
[+] NSS_BUILTINS_LIBRARY_VERSION_MINOR

nssutil.h
[+] NSSUTIL_VERSION
[+] NSSUTIL_VMINOR
[+] NSSUTIL_VPATCH

sslt.h
[+] SSL_MAX_EXTENSIONS

to the top

Other Changes in Constants (39)


nss.h
[+] NSS_DH_MIN_KEY_SIZE
[+] NSS_DSA_MIN_KEY_SIZE
[+] NSS_DTLS_VERSION_MAX_POLICY
[+] NSS_DTLS_VERSION_MIN_POLICY
[+] NSS_RSA_MIN_KEY_SIZE
[+] NSS_TLS_VERSION_MAX_POLICY
[+] NSS_TLS_VERSION_MIN_POLICY

pkcs11n.h
[+] CKK_NSS_CHACHA20
[+] CKM_NSS_CHACHA20_KEY_GEN
[+] CKM_NSS_CHACHA20_POLY1305
[+] CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE
[+] CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH

pkcs11t.h
[+] CKM_TLS12_KEY_AND_MAC_DERIVE
[+] CKM_TLS12_KEY_SAFE_DERIVE
[+] CKM_TLS12_MASTER_KEY_DERIVE
[+] CKM_TLS12_MASTER_KEY_DERIVE_DH
[+] CKM_TLS_KDF
[+] CKM_TLS_MAC
[+] CKP_PKCS5_PBKD2_HMAC_GOSTR3411
[+] CKP_PKCS5_PBKD2_HMAC_SHA224
[+] CKP_PKCS5_PBKD2_HMAC_SHA256
[+] CKP_PKCS5_PBKD2_HMAC_SHA384
[+] CKP_PKCS5_PBKD2_HMAC_SHA512
[+] CKP_PKCS5_PBKD2_HMAC_SHA512_224
[+] CKP_PKCS5_PBKD2_HMAC_SHA512_256

secoidt.h
[+] NSS_USE_ALG_IN_SSL
[+] NSS_USE_ALG_IN_SSL_KX
[+] NSS_USE_POLICY_IN_SSL

ssl.h
[+] SSL_ENABLE_EXTENDED_MASTER_SECRET
[+] SSL_ENABLE_SERVER_DHE
[+] SSL_ENABLE_SIGNED_CERT_TIMESTAMPS

sslproto.h
[+] TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
[+] TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
[+] TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
[+] TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
[+] TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256

sslt.h
[+] ssl_preinfo_all
[+] ssl_preinfo_cipher_suite
[+] ssl_preinfo_version

to the top

Header Files (95)


base64.h
blapit.h
cert.h
certdb.h
certt.h
ciferfam.h
cmmf.h
cmmft.h
cms.h
cmsreclist.h
cmst.h
crmf.h
crmft.h
cryptohi.h
cryptoht.h
ecl-exp.h
hasht.h
jar-ds.h
jar.h
jarfile.h
key.h
keyhi.h
keyt.h
keythi.h
nss.h
nssb64.h
nssb64t.h
nssbase.h
nssbaset.h
nssckbi.h
nssckepv.h
nssckft.h
nssckfw.h
nssckfwc.h
nssckfwt.h
nssckg.h
nssckmdt.h
nssckt.h
nssilckt.h
nssilock.h
nsslocks.h
nsslowhash.h
nssrwlk.h
nssrwlkt.h
nssutil.h
ocsp.h
ocspt.h
p12.h
p12plcy.h
p12t.h
pk11func.h
pk11pqg.h
pk11priv.h
pk11pub.h
pk11sdr.h
pkcs11.h
pkcs11f.h
pkcs11n.h
pkcs11p.h
pkcs11t.h
pkcs11u.h
pkcs12.h
pkcs12t.h
pkcs1sig.h
pkcs7t.h
portreg.h
preenc.h
secasn1.h
secasn1t.h
seccomon.h
secder.h
secdert.h
secdig.h
secdigt.h
secerr.h
sechash.h
secitem.h
secmime.h
secmod.h
secmodt.h
secoid.h
secoidt.h
secpkcs5.h
secpkcs7.h
secport.h
shsign.h
smime.h
ssl.h
sslerr.h
sslproto.h
sslt.h
utilmodt.h
utilpars.h
utilparst.h
utilrename.h

to the top

Shared Libraries (8)


libfreebl3.so
libnss3.so
libnssckbi.so
libnssdbm3.so
libnssutil3.so
libsmime3.so
libsoftokn3.so
libssl3.so

to the top






Reply to: