Bug 1244062 - Upgrade Firefox 47 to NSPR 4.12, a=sledru FIREFOX_RELEASE_45_BASE
authorKai Engert <kaie@kuix.de>
Mon, 29 Feb 2016 16:18:37 +0100
changeset 311420 bbe048ab30ad3321a6505697703e5fee20e91343
parent 311419 48e0d09b052cb157df2659be7ebaac1f0dff58d8
child 311421 0c0ee5ef7e4ddd6ec9144366b79feb8e2f6adec1
push id5691
push userkaie@kuix.de
push dateMon, 29 Feb 2016 15:18:46 +0000
treeherdermozilla-beta@bbe048ab30ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssledru
bugs1244062
milestone45.0
Bug 1244062 - Upgrade Firefox 47 to NSPR 4.12, a=sledru
configure.in
nsprpub/TAG-INFO
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/lib/ds/plarena.h
nsprpub/pr/include/md/_freebsd.cfg
nsprpub/pr/include/md/_freebsd.h
nsprpub/pr/include/md/_linux.h
nsprpub/pr/include/md/_netbsd.h
nsprpub/pr/include/md/_openbsd.h
nsprpub/pr/include/md/_unixos.h
nsprpub/pr/include/prenv.h
nsprpub/pr/include/prinit.h
nsprpub/pr/src/io/prlog.c
nsprpub/pr/src/io/prprf.c
nsprpub/pr/src/io/prscanf.c
nsprpub/pr/src/md/unix/unix.c
nsprpub/pr/src/md/windows/ntinrval.c
nsprpub/pr/src/md/windows/w95thred.c
nsprpub/pr/src/misc/prenv.c
nsprpub/pr/src/misc/prnetdb.c
nsprpub/pr/src/misc/prtpool.c
nsprpub/pr/src/misc/prtrace.c
nsprpub/pr/src/nspr.def
nsprpub/pr/src/pthreads/ptio.c
nsprpub/pr/src/pthreads/ptthread.c
nsprpub/pr/tests/env.c
nsprpub/pr/tests/server_test.c
nsprpub/pr/tests/vercheck.c
--- a/configure.in
+++ b/configure.in
@@ -48,17 +48,17 @@ dnl ====================================
 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
 
 dnl Set the version number of the libs included with mozilla
 dnl ========================================================
 MOZJPEG=62
 MOZPNG=10619
 NSPR_VERSION=4
-NSPR_MINVER=4.11
+NSPR_MINVER=4.12
 NSS_VERSION=3
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
 GLIB_VERSION=2.22
 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
 # The macro won't be used when compiling with earlier versions anyway.
 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_11_RTM
+NSPR_4_12_RTM
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -5,9 +5,8 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
-
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -2483,17 +2483,17 @@ case $target_os in *\ *) target_os=`echo
 # The aliases save the names the user supplied, while $host etc.
 # will get canonicalized.
 test -n "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=11
+MOD_MINOR_VERSION=12
 MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_X32=
@@ -7043,20 +7043,16 @@ tools are selected during the Xcode/Deve
     powerpc64)
         if test -n "$USE_64"; then
             CC="$CC -m64"
             CXX="$CXX -m64"
         else
             PR_MD_ASFILES=os_Linux_ppc.s
         fi
         ;;
-    m68k)
-        CFLAGS="$CFLAGS -m68020-60"
-        CXXFLAGS="$CXXFLAGS -m68020-60"
-        ;;
     esac
     ;;
 
 *-mingw*|*-msys*|*-cygwin*|*-mks*)
     $as_echo "#define XP_PC 1" >>confdefs.h
 
     $as_echo "#define WIN32 1" >>confdefs.h
 
@@ -7889,17 +7885,17 @@ fi
 $as_echo "$ac_cv_prog_gcc_traditional" >&6; }
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 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"
 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -10,17 +10,17 @@ AC_CONFIG_SRCDIR([pr/include/nspr.h])
 
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_TARGET
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=11
+MOD_MINOR_VERSION=12
 MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_X32=
@@ -1851,20 +1851,16 @@ tools are selected during the Xcode/Deve
     powerpc64)
         if test -n "$USE_64"; then
             CC="$CC -m64"
             CXX="$CXX -m64"
         else
             PR_MD_ASFILES=os_Linux_ppc.s
         fi
         ;;
-    m68k)
-        CFLAGS="$CFLAGS -m68020-60"
-        CXXFLAGS="$CXXFLAGS -m68020-60"
-        ;;
     esac    
     ;;
 
 *-mingw*|*-msys*|*-cygwin*|*-mks*)
     AC_DEFINE(XP_PC)
     AC_DEFINE(WIN32)
     PR_MD_ARCH_DIR=windows
     RESOLVE_LINK_SYMBOLS=1
@@ -2538,17 +2534,18 @@ dnl Check for typedefs and structs
 dnl ========================================================
 
 dnl ========================================================
 dnl Checks for library functions.
 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 ========================================================
 dnl Check options
 dnl ========================================================
 
 dnl ======================================================
 dnl = Enable compiling with ccache
--- a/nsprpub/lib/ds/plarena.h
+++ b/nsprpub/lib/ds/plarena.h
@@ -91,21 +91,21 @@ struct PLArenaPool {
 #elif defined(__SANITIZE_ADDRESS__)
 #define PL_SANITIZE_ADDRESS 1
 #endif
 
 #if defined(PL_SANITIZE_ADDRESS)
 
 /* 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))
 
 #define PL_MAKE_MEM_UNDEFINED(addr, size) \
     __asan_unpoison_memory_region((addr), (size))
 
 #define PL_MAKE_MEM_DEFINED(addr, size) \
--- a/nsprpub/pr/include/md/_freebsd.cfg
+++ b/nsprpub/pr/include/md/_freebsd.cfg
@@ -337,16 +337,62 @@
 #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
--- a/nsprpub/pr/include/md/_freebsd.h
+++ b/nsprpub/pr/include/md/_freebsd.h
@@ -24,16 +24,18 @@
 #elif defined(__ia64__)
 #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"
@@ -223,17 +225,17 @@ extern PRStatus _MD_WAKEUP_WAITER(PRThre
 extern void _MD_YIELD(void);
 
 #endif /* ! _PR_PTHREADS */
 
 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,
  * unwrapped version.
  */
 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
 
 #if defined(_PR_POLL_AVAILABLE)
--- a/nsprpub/pr/include/md/_linux.h
+++ b/nsprpub/pr/include/md/_linux.h
@@ -666,17 +666,17 @@ extern PRStatus _MD_WAKEUP_WAITER(PRThre
 extern void _MD_YIELD(void);
 
 #endif /* ! _PR_PTHREADS */
 
 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,
  * unwrapped version.
  */
 #define _MD_SELECT __select
 
 #ifdef _PR_POLL_AVAILABLE
--- a/nsprpub/pr/include/md/_netbsd.h
+++ b/nsprpub/pr/include/md/_netbsd.h
@@ -206,17 +206,17 @@ struct _MDCPU {
 #define _MD_CLEAN_THREAD(_thread)
 
 #endif /* ! _PR_PTHREADS */
 
 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,
  * unwrapped version.
  */
 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
 #if defined(_PR_POLL_AVAILABLE)
 #include <poll.h>
--- a/nsprpub/pr/include/md/_openbsd.h
+++ b/nsprpub/pr/include/md/_openbsd.h
@@ -187,17 +187,17 @@ struct _MDCPU {
 #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
 #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
 #define _MD_CLEAN_THREAD(_thread)
 
 #endif /* ! _PR_PTHREADS */
 
 #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,
  * unwrapped version.
  */
 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
 #include <poll.h>
 #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
--- a/nsprpub/pr/include/md/_unixos.h
+++ b/nsprpub/pr/include/md/_unixos.h
@@ -297,17 +297,17 @@ extern void		_MD_FreeSegment(PRSegment *
 #ifdef _MD_INTERVAL_USE_GTOD
 extern PRIntervalTime   _PR_UNIX_GetInterval(void);
 extern PRIntervalTime   _PR_UNIX_TicksPerSecond(void);
 #define _MD_INTERVAL_INIT()
 #define _MD_GET_INTERVAL		_PR_UNIX_GetInterval
 #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()
 #define _MD_GET_INTERVAL		_PR_UNIX_GetInterval2
 #define _MD_INTERVAL_PER_SEC		_PR_UNIX_TicksPerSecond2
 #endif
 
 #define _MD_INTERVAL_PER_MILLISEC()	(_PR_MD_INTERVAL_PER_SEC() / 1000)
--- a/nsprpub/pr/include/prenv.h
+++ b/nsprpub/pr/include/prenv.h
@@ -86,16 +86,30 @@ PR_BEGIN_EXTERN_C
 **   conceptual environment space than that operated upon by
 **   NSPR's functions or other environment manipulating
 **   functions on the same platform. (!)
 ** 
 */
 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:
 ** PR_SetEnv() is modeled on the Unix putenv() function.
 ** 
 ** Inputs: 
 **   string -- pointer to a caller supplied
 **   constant, persistent string of the form name=value. Where
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -26,19 +26,19 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.11"
+#define PR_VERSION  "4.12"
 #define PR_VMAJOR   4
-#define PR_VMINOR   11
+#define PR_VMINOR   12
 #define PR_VPATCH   0
 #define PR_BETA     PR_FALSE
 
 /*
 ** PRVersionCheck
 **
 ** The basic signature of the function that is called to provide version
 ** checking. The result will be a boolean that indicates the likelihood
--- a/nsprpub/pr/src/io/prlog.c
+++ b/nsprpub/pr/src/io/prlog.c
@@ -233,23 +233,17 @@ void _PR_InitLog(void)
             }
             /*found:*/
             count = sscanf(&ev[pos], " , %n", &delta);
             pos += delta;
             if (count == EOF) break;
         }
         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
                 char* str = PR_smprintf("Unable to create nspr log file '%s'\n", ev);
                 if (str) {
                     OutputDebugStringA(str);
                     PR_smprintf_free(str);
                 }
--- a/nsprpub/pr/src/io/prprf.c
+++ b/nsprpub/pr/src/io/prprf.c
@@ -32,17 +32,17 @@
 
 typedef struct SprintfStateStr SprintfState;
 
 struct SprintfStateStr {
     int (*stuff)(SprintfState *ss, const char *sp, PRUint32 len);
 
     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;
 };
 
 /*
 ** Numbered Argument
 */
@@ -692,17 +692,17 @@ static int dosprintf(SprintfState *ss, c
 #endif
     } u;
     const char *fmt0;
     static char *hex = "0123456789abcdef";
     static char *HEX = "0123456789ABCDEF";
     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 . */
 #ifdef WIN32
     char *pBuf = NULL;
 #endif
 
     /*
@@ -1055,16 +1055,23 @@ static int dosprintf(SprintfState *ss, c
 }
 
 /************************************************************************/
 
 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;
     }
     ss->maxlen += len;
     return 0;
 }
 
@@ -1100,19 +1107,31 @@ PR_IMPLEMENT(PRUint32) PR_vsxprintf(PRSt
 */
 static int GrowStuff(SprintfState *ss, const char *sp, PRUint32 len)
 {
     ptrdiff_t off;
     char *newbase;
     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 {
 	    newbase = (char*) PR_MALLOC(newlen);
 	}
 	if (!newbase) {
 	    /* Ran out of memory */
 	    return -1;
@@ -1205,18 +1224,18 @@ PR_IMPLEMENT(PRUint32) PR_snprintf(char 
 }
 
 PR_IMPLEMENT(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen,const char *fmt,
                                   va_list ap)
 {
     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;
     }
 
     ss.stuff = LimitStuff;
     ss.base = out;
     ss.cur = out;
     ss.maxlen = outlen;
     (void) dosprintf(&ss, fmt, ap);
@@ -1242,17 +1261,20 @@ PR_IMPLEMENT(char *) PR_sprintf_append(c
 
 PR_IMPLEMENT(char *) PR_vsprintf_append(char *last, const char *fmt, va_list ap)
 {
     SprintfState ss;
     int rv;
 
     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;
     } else {
 	ss.base = 0;
 	ss.cur = 0;
 	ss.maxlen = 0;
     }
--- a/nsprpub/pr/src/io/prscanf.c
+++ b/nsprpub/pr/src/io/prscanf.c
@@ -189,17 +189,17 @@ static PRUint64
  */
 #define FMAX 31
 #define DECIMAL_POINT '.'
 
 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;
     int dlen;
 
     switch (code) {
         case 'd': case 'u':
             base = 10;
@@ -299,17 +299,17 @@ GetInt(ScanfState *state, int code)
     }
     return PR_SUCCESS;
 }
 
 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) {
         state->width = FMAX;
     }
     p = buf;
     GET_IF_WITHIN_WIDTH(state, ch);
     if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {
--- a/nsprpub/pr/src/md/unix/unix.c
+++ b/nsprpub/pr/src/md/unix/unix.c
@@ -2710,17 +2710,17 @@ static void* _MD_Unix_mmap64(
 {
     PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);
     return NULL;
 }  /* _MD_Unix_mmap64 */
 #endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */
 
 /* 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
 
 static void *
 mmap64(void *addr, size_t len, int prot, int flags, int fd, loff_t offset)
 {
     if (offset & (ANDROID_PAGE_SIZE - 1)) {
         errno = EINVAL;
@@ -3035,17 +3035,17 @@ PRIntervalTime _PR_UNIX_GetInterval()
 }  /* _PR_UNIX_GetInterval */
 
 PRIntervalTime _PR_UNIX_TicksPerSecond()
 {
     return 1000;  /* this needs some work :) */
 }
 #endif
 
-#if defined(HAVE_CLOCK_MONOTONIC)
+#if defined(_PR_HAVE_CLOCK_MONOTONIC)
 PRIntervalTime _PR_UNIX_GetInterval2()
 {
     struct timespec time;
     PRIntervalTime ticks;
 
     if (clock_gettime(CLOCK_MONOTONIC, &time) != 0) {
         fprintf(stderr, "clock_gettime failed: %d\n", errno);
         abort();
--- a/nsprpub/pr/src/md/windows/ntinrval.c
+++ b/nsprpub/pr/src/md/windows/ntinrval.c
@@ -3,16 +3,20 @@
  * 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/. */
 
 /*
  * NT interval timers
  *
  */
 
+/* Mozilla's build system defines this globally. */
+#ifdef WIN32_LEAN_AND_MEAN
+#undef WIN32_LEAN_AND_MEAN
+#endif
 #include "primpl.h"
 
 #ifdef WINCE
 typedef DWORD (*IntervalFuncType)(void);
 static IntervalFuncType intervalFunc;
 #endif
 
 void
--- a/nsprpub/pr/src/md/windows/w95thred.c
+++ b/nsprpub/pr/src/md/windows/w95thred.c
@@ -60,24 +60,29 @@ PRStatus
         ** Warning:
         ** --------
         ** NSPR requires a real handle to every thread.
         ** GetCurrentThread() returns a pseudo-handle which
         ** is not suitable for some thread operations (e.g.,
         ** 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 */
                 &(thread->md.handle),    /* resulting handle */
                 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 */
     thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);
     if (thread->md.blocked_sema == NULL)
         return PR_FAILURE;
 	else
 		return PR_SUCCESS;
--- a/nsprpub/pr/src/misc/prenv.c
+++ b/nsprpub/pr/src/misc/prenv.c
@@ -1,27 +1,34 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #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)
 #define _PR_NEW_LOCK_ENV()
 #define _PR_DELETE_LOCK_ENV()
 #define _PR_LOCK_ENV()
 #define _PR_UNLOCK_ENV()
 #elif defined(_PR_LOCAL_THREADS_ONLY)
 extern _PRCPU * _pr_primordialCPU;
@@ -58,16 +65,44 @@ PR_IMPLEMENT(char*) PR_GetEnv(const char
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     _PR_LOCK_ENV();
     ev = _PR_MD_GET_ENV(var);
     _PR_UNLOCK_ENV();
     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);
 
--- a/nsprpub/pr/src/misc/prnetdb.c
+++ b/nsprpub/pr/src/misc/prnetdb.c
@@ -58,18 +58,17 @@ PRLock *_pr_dnsLock = NULL;
 #include <arpa/inet.h>  /* pick up define for inet_addr */
 #include <sys/socket.h>
 #define _PR_HAVE_GETPROTO_R
 #define _PR_HAVE_GETPROTO_R_POINTER
 #endif
 
 #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
 
 #if defined(OSF1) \
         || defined(AIX4_3_PLUS) || (defined(AIX) && defined(_THREAD_SAFE)) \
 	|| (defined(HPUX10_10) && defined(_REENTRANT)) \
         || (defined(HPUX10_20) && defined(_REENTRANT)) \
--- a/nsprpub/pr/src/misc/prtpool.c
+++ b/nsprpub/pr/src/misc/prtpool.c
@@ -276,18 +276,18 @@ add_to_jobq(PRThreadPool *tp, PRJob *job
  * io worker thread function
  */
 static void io_wstart(void *arg)
 {
 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;
 
 	/*
 	 * scan io_jobq
 	 * construct poll list
 	 * call PR_Poll
 	 * for all fds, for which poll returns true, move the job to
--- a/nsprpub/pr/src/misc/prtrace.c
+++ b/nsprpub/pr/src/misc/prtrace.c
@@ -652,24 +652,18 @@ static PRFileDesc * InitializeRecording(
         _PR_InitializeTrace();
 
     PR_LOG( lm, PR_LOG_DEBUG,
         ("PR_RecordTraceEntries: begins"));
 
     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,
             ("RecordTraceEntries: Environment variable not defined. Exiting"));
         return NULL;
     }
     
     /* Open the logfile */
--- a/nsprpub/pr/src/nspr.def
+++ b/nsprpub/pr/src/nspr.def
@@ -450,8 +450,15 @@ EXPORTS ;-
 ;+      global:
 		PR_GetThreadName;
 		PR_SetCurrentThreadName;
 ;+} NSPR_4.8.9;
 ;+NSPR_4.10.3 {
 ;+      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;
--- a/nsprpub/pr/src/pthreads/ptio.c
+++ b/nsprpub/pr/src/pthreads/ptio.c
@@ -3760,17 +3760,17 @@ static PRInt32 _pr_poll_with_poll(
     PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
 {
     PRInt32 ready = 0;
     /*
      * For restarting poll() if it is interrupted by a signal.
      * 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;
 
     if (0 == npds) PR_Sleep(timeout);
     else
     {
 #define STACK_POLL_DESC_COUNT 64
         struct pollfd stack_syspoll[STACK_POLL_DESC_COUNT];
@@ -4014,17 +4014,17 @@ static PRInt32 _pr_poll_with_select(
     PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
 {
     PRInt32 ready = 0;
     /*
      * For restarting select() if it is interrupted by a signal.
      * 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;
 
     if (0 == npds) PR_Sleep(timeout);
     else
     {
 #define STACK_POLL_DESC_COUNT 64
         int stack_selectfd[STACK_POLL_DESC_COUNT];
@@ -4914,17 +4914,17 @@ PR_IMPLEMENT(PRInt32) PR_Select(
     struct timeval tv, *tvp;
     PRInt32 max, max_fd;
     PRInt32 rv;
     /*
      * For restarting select() if it is interrupted by a Unix signal.
      * 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");
 
     FD_ZERO(&rd);
     FD_ZERO(&wr);
     FD_ZERO(&ex);
 
--- a/nsprpub/pr/src/pthreads/ptthread.c
+++ b/nsprpub/pr/src/pthreads/ptthread.c
@@ -16,16 +16,20 @@
 #include "prpdce.h"
 
 #include <pthread.h>
 #include <unistd.h>
 #include <string.h>
 #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.
  */
 #undef _POSIX_THREAD_PRIORITY_SCHEDULING
 #endif
 
 #ifdef _PR_NICE_PRIORITY_SCHEDULING
@@ -1728,17 +1732,17 @@ PR_IMPLEMENT(void*)PR_GetSP(PRThread *th
 }  /* PR_GetSP */
 
 #endif /* !defined(_PR_DCETHREADS) */
 
 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);
         return PR_FAILURE;
     }
 
     thread = PR_GetCurrentThread();
     if (!thread)
@@ -1746,18 +1750,20 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThre
 
     PR_Free(thread->name);
     nameLen = strlen(name);
     thread->name = (char *)PR_Malloc(nameLen + 1);
     if (!thread->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
      * for it at runtime.  It also may not be available on all linux distros.
      */
 #if defined(DARWIN)
     int (*dynamic_pthread_setname_np)(const char*);
 #else
--- a/nsprpub/pr/tests/env.c
+++ b/nsprpub/pr/tests/env.c
@@ -13,16 +13,17 @@
 #include "plgetopt.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 PRIntn  debug = 0;
 PRIntn  verbose = 0;
+PRIntn  secure = 0;
 PRBool  failedAlready = PR_FALSE;
 
 #define  ENVNAME    "NSPR_ENVIRONMENT_TEST_VARIABLE"
 #define  ENVVALUE   "The expected result"
 #define  ENVBUFSIZE 256
 
 char    *envBuf; /* buffer pointer. We leak memory here on purpose! */
 
@@ -38,29 +39,38 @@ static char * NewBuffer( size_t size )
 
 int main(int argc, char **argv)
 {
     char    *value;
     PRStatus    rc;
 
     {   /* 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)))
         {
 		    if (PL_OPT_BAD == os) continue;
             switch (opt->option)
             {
             case 'd':  /* debug */
                 debug = 1;
                 break;
             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;
             }
         }
 	    PL_DestroyOptState(opt);
     } /* end block "Get command line options" */
 
 #if 0 
@@ -108,16 +118,42 @@ int main(int argc, char **argv)
     value = PR_GetEnv( ENVNAME );
     if ( (NULL == value ) || (strcmp( value, ENVVALUE)))  {
         if (debug) printf( "env: PR_GetEnv() Failed after setting\n" );
         failedAlready = PR_TRUE;
     } else {
         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
--- a/nsprpub/pr/tests/server_test.c
+++ b/nsprpub/pr/tests/server_test.c
@@ -32,16 +32,17 @@
 #include <string.h>
 
 #define PORT 15004
 #define THREAD_STACKSIZE 0
 
 #define PASS 0
 #define FAIL 1
 static int debug_mode = 0;
+static int failed_already = 0;
 
 static int _iterations = 1000;
 static int _clients = 1;
 static int _client_data = 250;
 static int _server_data = (8*1024);
 
 static PRThreadScope ServerScope, ClientScope;
 
@@ -85,16 +86,17 @@ static void Test_Result (int result)
 {
 	switch (result)
 	{
 		case PASS:
 			printf ("PASS\n");
 			break;
 		case FAIL:
 			printf ("FAIL\n");
+			failed_already = 1;
 			break;
 		default:
 			break;
 	}
 }
 
 static void do_work(void);
 
@@ -241,39 +243,50 @@ WorkerThreadFunc(void *_listenSock)
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 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);
         PR_Close(listenSocket);
         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);
 
         return NULL;
     }
 
     /* Create Clients */
@@ -543,17 +556,17 @@ int main(int argc, char **argv)
 {
 	/* The command line argument: -d is used to determine if the test is being run
 	in debug mode. The regress tool requires only one line output:PASS or FAIL.
 	All of the printfs associated with this test has been handled with a if (debug_mode)
 	test.
 	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;
         switch (opt->option)
         {
         case 'd':  /* debug mode */
 			debug_mode = 1;
             break;
@@ -601,10 +614,10 @@ int main(int argc, char **argv)
  #if 0 
     Measure(do_workUK, "server loop user/kernel");
     Measure(do_workKU, "server loop kernel/user");
     Measure(do_workKK, "server loop kernel/kernel");
  #endif 
 
     PR_Cleanup();
 
-    return 0;
+    return failed_already;
 }
--- a/nsprpub/pr/tests/vercheck.c
+++ b/nsprpub/pr/tests/vercheck.c
@@ -17,51 +17,51 @@
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
  * 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, and 4.10.x 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[] = {
     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
     "4.5", "4.5.1",
     "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5",
     "4.6.6", "4.6.7", "4.6.8",
     "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5",
     "4.7.6",
     "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5",
     "4.8.6", "4.8.7", "4.8.8", "4.8.9",
     "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.7", "4.10.8", "4.10.9",
-    "4.10.10",
+    "4.10.10", "4.11",
     PR_VERSION
 };
 
 /*
  * This release is not backward compatible with the old
  * NSPR 2.1 and 3.x releases.
  *
  * Any release is incompatible with future releases and
  * patches.
  */
 static char *incompatible_version[] = {
     "2.1 19980529",
     "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", "4.12.1",
+    "4.12.1",
     "10.0", "11.1", "12.14.20"
 };
 
 int main(int argc, char **argv)
 {
     int idx;
     int num_compatible = sizeof(compatible_version) / sizeof(char *);
     int num_incompatible = sizeof(incompatible_version) / sizeof(char *);