[-]
[+]
|
Changed |
_service:tar_git:nspr.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:nspr.spec
^
|
|
|
Changed |
_service
^
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/.hg_archival.txt
^
|
@@ -1,4 +1,4 @@
repo: a4b34919bf34db2ee22acbbc305693c8980b6dc6
-node: 21a7c4a68ca663ae2ba8ff05e12b9379f5108c5d
+node: 3e67abaf5669114ac87d89c60eb0f0b73a086a2e
branch: default
-tag: NSPR_4_10_10_RTM
+tag: NSPR_4_17_RTM
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/.hgignore
^
|
@@ -3,3 +3,5 @@
*OPT.OBJ/*
*DBG.OBJ/*
*DBG.OBJD/*
+Debug/
+Release/
|
[-]
[+]
|
Added |
_service:tar_git:nspr-4.17.tar.gz/nspr/automation/release/nspr-release-helper.py
^
|
@@ -0,0 +1,179 @@
+#!/usr/bin/python
+# 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/.
+
+
+import os
+import sys
+import datetime
+import shutil
+import glob
+from optparse import OptionParser
+from subprocess import check_call
+
+prinit_h = "pr/include/prinit.h"
+f_conf = "configure"
+f_conf_in = "configure.in"
+
+def check_call_noisy(cmd, *args, **kwargs):
+ print "Executing command:", cmd
+ check_call(cmd, *args, **kwargs)
+
+o = OptionParser(usage="client.py [options] remove_beta | set_beta | print_library_versions | set_version_to_minor_release | set_version_to_patch_release | create_nspr_release_archive")
+
+try:
+ options, args = o.parse_args()
+ action = args[0]
+except IndexError:
+ o.print_help()
+ sys.exit(2)
+
+def exit_with_failure(what):
+ print "failure: ", what
+ sys.exit(2)
+
+def check_files_exist():
+ if (not os.path.exists(prinit_h)):
+ exit_with_failure("cannot find expected header files, must run from inside NSPR hg directory")
+
+def sed_inplace(sed_expression, filename):
+ backup_file = filename + '.tmp'
+ check_call_noisy(["sed", "-i.tmp", sed_expression, filename])
+ os.remove(backup_file)
+
+def toggle_beta_status(is_beta):
+ check_files_exist()
+ if (is_beta):
+ print "adding Beta status to version numbers"
+ sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', prinit_h)
+ sed_inplace('s/^\(#define *PR_BETA *\)PR_FALSE *$/\\1PR_TRUE/', prinit_h)
+
+ else:
+ print "removing Beta status from version numbers"
+ sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', prinit_h)
+ sed_inplace('s/^\(#define *PR_BETA *\)PR_TRUE *$/\\1PR_FALSE/', prinit_h)
+ print "please run 'hg stat' and 'hg diff' to verify the files have been verified correctly"
+
+def print_beta_versions():
+ check_call_noisy(["egrep", "#define *PR_VERSION|#define *PR_BETA", prinit_h])
+
+def remove_beta_status():
+ print "--- removing beta flags. Existing versions were:"
+ print_beta_versions()
+ toggle_beta_status(False)
+ print "--- finished modifications, new versions are:"
+ print_beta_versions()
+
+def set_beta_status():
+ print "--- adding beta flags. Existing versions were:"
+ print_beta_versions()
+ toggle_beta_status(True)
+ print "--- finished modifications, new versions are:"
+ print_beta_versions()
+
+def print_library_versions():
+ check_files_exist()
+ check_call_noisy(["egrep", "#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA", prinit_h])
+
+def ensure_arguments_after_action(how_many, usage):
+ if (len(sys.argv) != (2+how_many)):
+ exit_with_failure("incorrect number of arguments, expected parameters are:\n" + usage)
+
+def set_major_versions(major):
+ sed_inplace('s/^\(#define *PR_VMAJOR *\).*$/\\1' + major + '/', prinit_h)
+ sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf)
+ sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf_in)
+
+def set_minor_versions(minor):
+ sed_inplace('s/^\(#define *PR_VMINOR *\).*$/\\1' + minor + '/', prinit_h)
+ sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf)
+ sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf_in)
+
+def set_patch_versions(patch):
+ sed_inplace('s/^\(#define *PR_VPATCH *\).*$/\\1' + patch + '/', prinit_h)
+ sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf)
+ sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf_in)
+
+def set_full_lib_versions(version):
+ sed_inplace('s/^\(#define *PR_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', prinit_h)
+
+def set_all_lib_versions(version, major, minor, patch):
+ set_full_lib_versions(version)
+ set_major_versions(major)
+ set_minor_versions(minor)
+ set_patch_versions(patch)
+ print
+ print "==========================="
+ print "======== ATTENTION ========"
+ print
+ print "You *MUST* manually edit file pr/tests/vercheck.c"
+ print
+ print "Edit two arrays, named compatible_version and incompatible_version"
+ print "according to the new version you're adding."
+ print
+ print "======== ATTENTION ========"
+ print "==========================="
+
+def set_version_to_minor_release():
+ ensure_arguments_after_action(2, "major_version minor_version")
+ major = args[1].strip()
+ minor = args[2].strip()
+ version = major + '.' + minor
+ patch = "0"
+ set_all_lib_versions(version, major, minor, patch)
+
+def set_version_to_patch_release():
+ ensure_arguments_after_action(3, "major_version minor_version patch_release")
+ major = args[1].strip()
+ minor = args[2].strip()
+ patch = args[3].strip()
+ version = major + '.' + minor + '.' + patch
+ set_all_lib_versions(version, major, minor, patch)
+
+def create_nspr_release_archive():
+ ensure_arguments_after_action(2, "nspr_release_version nspr_hg_release_tag")
+ nsprrel = args[1].strip() #e.g. 4.10.9
+ nsprreltag = args[2].strip() #e.g. NSPR_4_10_9_RTM
+
+ nspr_tar = "nspr-" + nsprrel + ".tar.gz"
+ nspr_stagedir="../stage/v" + nsprrel + "/src"
+ if (os.path.exists(nspr_stagedir)):
+ exit_with_failure("nspr stage directory already exists: " + nspr_stagedir)
+
+ check_call_noisy(["mkdir", "-p", nspr_stagedir])
+ check_call_noisy(["hg", "archive", "-r", nsprreltag, "--prefix=nspr-" + nsprrel + "/nspr",
+ "../stage/v" + nsprrel + "/src/" + nspr_tar, "-X", ".hgtags"])
+ print "changing to directory " + nspr_stagedir
+ os.chdir(nspr_stagedir)
+
+ check_call("sha1sum " + nspr_tar + " > SHA1SUMS", shell=True)
+ check_call("sha256sum " + nspr_tar + " > SHA256SUMS", shell=True)
+ print "created directory " + nspr_stagedir + " with files:"
+ check_call_noisy(["ls", "-l"])
+
+if action in ('remove_beta'):
+ remove_beta_status()
+
+elif action in ('set_beta'):
+ set_beta_status()
+
+elif action in ('print_library_versions'):
+ print_library_versions()
+
+# x.y version number - 2 parameters
+elif action in ('set_version_to_minor_release'):
+ set_version_to_minor_release()
+
+# x.y.z version number - 3 parameters
+elif action in ('set_version_to_patch_release'):
+ set_version_to_patch_release()
+
+elif action in ('create_nspr_release_archive'):
+ create_nspr_release_archive()
+
+else:
+ o.print_help()
+ sys.exit(2)
+
+sys.exit(0)
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/configure
^
|
@@ -2488,8 +2488,8 @@
program_prefix=${target_alias}-
MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=10
+MOD_MINOR_VERSION=17
+MOD_PATCH_VERSION=0
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@@ -5424,6 +5424,40 @@
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma diagnostic" >&5
+$as_echo_n "checking for pragma diagnostic... " >&6; }
+if test "$GNU_CC" = "1"; then
+ cat >dummy-hello.c <<EOF
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
+int main() {
+ char *dummy = "";
+ return 0;
+}
+EOF
+ ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
+ if test $? != 0; then
+ ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
+ if test $? = 0; then
+ CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
+ _res=yes
+ else
+ _res=no
+ fi
+ else
+ _res=no
+ fi
+ rm -f dummy-hello.c dummy-hello.s
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_res" >&5
+$as_echo "$_res" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
@@ -6524,6 +6558,13 @@
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
+ HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
+ if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
+ $as_echo "#define HAS_CONNECTX 1" >>confdefs.h
+ fi
+
AS='$(CC) -x assembler-with-cpp'
CFLAGS="$CFLAGS -Wall -fno-common"
case "${target_cpu}" in
@@ -6673,6 +6714,8 @@
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
if test "$MOZ_OBJFORMAT" = "elf"; then
@@ -6975,6 +7018,8 @@
$as_echo "#define HAVE_FCNTL_FILE_LOCKING 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
case "${target}" in
*-android*|*-linuxandroid*)
OS_TARGET=Android
@@ -7048,10 +7093,6 @@
PR_MD_ASFILES=os_Linux_ppc.s
fi
;;
- m68k)
- CFLAGS="$CFLAGS -m68020-60"
- CXXFLAGS="$CXXFLAGS -m68020-60"
- ;;
esac
;;
@@ -7285,6 +7326,8 @@
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1
fi
@@ -7341,6 +7384,8 @@
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
CFLAGS="$CFLAGS -ansi -Wall"
CXXFLAGS="$CXXFLAGS -ansi -Wall"
DLL_SUFFIX=so.1.0
@@ -7894,7 +7939,7 @@
_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"
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/configure.in
^
|
@@ -15,8 +15,8 @@
dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=10
+MOD_MINOR_VERSION=17
+MOD_PATCH_VERSION=0
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@@ -716,6 +716,40 @@
fi
dnl ========================================================
+dnl Check for pragma diagnostic
+dnl ========================================================
+
+AC_MSG_CHECKING([for pragma diagnostic])
+if test "$GNU_CC" = "1"; then
+ cat >dummy-hello.c <<EOF
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
+int main() {
+ char *dummy = "";
+ return 0;
+}
+EOF
+ ${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
+ if test $? != 0; then
+ ${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
+ if test $? = 0; then
+ CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
+ _res=yes
+ else
+ _res=no
+ fi
+ else
+ _res=no
+ fi
+ rm -f dummy-hello.c dummy-hello.s
+ AC_MSG_RESULT([$_res])
+else
+ AC_MSG_RESULT([no])
+fi
+
+dnl ========================================================
dnl Profile guided optimization
dnl ========================================================
dnl Test for profiling options
@@ -1349,6 +1383,13 @@
AC_DEFINE(DARWIN)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
+ changequote(,)
+ HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
+ changequote([,])
+ if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
+ AC_DEFINE(HAS_CONNECTX)
+ fi
AS='$(CC) -x assembler-with-cpp'
CFLAGS="$CFLAGS -Wall -fno-common"
case "${target_cpu}" in
@@ -1519,6 +1560,7 @@
AC_DEFINE(FREEBSD)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
if test "$MOZ_OBJFORMAT" = "elf"; then
@@ -1789,6 +1831,7 @@
AC_DEFINE(XP_UNIX)
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
case "${target}" in
*-android*|*-linuxandroid*)
OS_TARGET=Android
@@ -1856,10 +1899,6 @@
PR_MD_ASFILES=os_Linux_ppc.s
fi
;;
- m68k)
- CFLAGS="$CFLAGS -m68020-60"
- CXXFLAGS="$CXXFLAGS -m68020-60"
- ;;
esac
;;
@@ -2082,6 +2121,7 @@
AC_DEFINE(NETBSD)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1
fi
@@ -2130,6 +2170,7 @@
AC_DEFINE(OPENBSD)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
CFLAGS="$CFLAGS -ansi -Wall"
CXXFLAGS="$CXXFLAGS -ansi -Wall"
DLL_SUFFIX=so.1.0
@@ -2543,7 +2584,8 @@
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 ========================================================
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/ds/plarena.c
^
|
@@ -17,8 +17,6 @@
#include "prlock.h"
#include "prinit.h"
-static PLArena *arena_freelist;
-
#ifdef PL_ARENAMETER
static PLArenaStats *arena_stats_list;
@@ -29,49 +27,6 @@
#define PL_ARENA_DEFAULT_ALIGN sizeof(double)
-static PRLock *arenaLock;
-static PRCallOnceType once;
-static const PRCallOnceType pristineCallOnce;
-
-/*
-** InitializeArenas() -- Initialize arena operations.
-**
-** InitializeArenas() is called exactly once and only once from
-** LockArena(). This function creates the arena protection
-** lock: arenaLock.
-**
-** Note: If the arenaLock cannot be created, InitializeArenas()
-** fails quietly, returning only PR_FAILURE. This percolates up
-** to the application using the Arena API. He gets no arena
-** from PL_ArenaAllocate(). It's up to him to fail gracefully
-** or recover.
-**
-*/
-static PRStatus InitializeArenas( void )
-{
- PR_ASSERT( arenaLock == NULL );
- arenaLock = PR_NewLock();
- if ( arenaLock == NULL )
- return PR_FAILURE;
- else
- return PR_SUCCESS;
-} /* end ArenaInitialize() */
-
-static PRStatus LockArena( void )
-{
- PRStatus rc = PR_CallOnce( &once, InitializeArenas );
-
- if ( PR_FAILURE != rc )
- PR_Lock( arenaLock );
- return(rc);
-} /* end LockArena() */
-
-static void UnlockArena( void )
-{
- PR_Unlock( arenaLock );
- return;
-} /* end UnlockArena() */
-
PR_IMPLEMENT(void) PL_InitArenaPool(
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
{
@@ -124,14 +79,7 @@
** pool.
**
** First, try to satisfy the request from arenas starting at
-** pool->current.
-**
-** If there is not enough space in the arena pool->current, try
-** to claim an arena, on a first fit basis, from the global
-** freelist (arena_freelist).
-**
-** If no arena in arena_freelist is suitable, then try to
-** allocate a new arena from the heap.
+** pool->current. Then try to allocate a new arena from the heap.
**
** Returns: pointer to allocated space or NULL
**
@@ -169,37 +117,6 @@
} while( NULL != (a = a->next) );
}
- /* attempt to allocate from arena_freelist */
- {
- PLArena *p; /* previous pointer, for unlinking from freelist */
-
- /* lock the arena_freelist. Make access to the freelist MT-Safe */
- if ( PR_FAILURE == LockArena())
- return(0);
-
- for ( a = arena_freelist, p = NULL; a != NULL ; p = a, a = a->next ) {
- if ( nb <= a->limit - a->base ) {
- if ( p == NULL )
- arena_freelist = a->next;
- else
- p->next = a->next;
- UnlockArena();
- a->avail = a->base;
- rp = (char *)a->avail;
- a->avail += nb;
- /* 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;
- return(rp);
- }
- }
- UnlockArena();
- }
-
/* attempt to allocate from the heap */
{
PRUint32 sz = PR_MAX(pool->arenasize, nb);
@@ -246,10 +163,11 @@
return newp;
}
-static void ClearArenaList(PLArena *a, PRInt32 pattern)
+PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
{
+ PLArena *a;
- for (; a; a = a->next) {
+ for (a = pool->first.next; a; a = a->next) {
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
a->avail = a->base;
PL_CLEAR_UNUSED_PATTERN(a, pattern);
@@ -257,48 +175,25 @@
}
}
-PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
-{
- ClearArenaList(pool->first.next, pattern);
-}
-
/*
* Free tail arenas linked after head, which may not be the true list head.
* Reset pool->current to point to head in case it pointed at a tail arena.
*/
-static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
+static void FreeArenaList(PLArenaPool *pool, PLArena *head)
{
- PLArena **ap, *a;
-
- ap = &head->next;
- a = *ap;
+ PLArena *a = head->next;
if (!a)
return;
-#ifdef DEBUG
- ClearArenaList(a, PL_FREE_PATTERN);
-#endif
+ head->next = NULL;
- if (reallyFree) {
- do {
- *ap = a->next;
- PL_CLEAR_ARENA(a);
- PL_COUNT_ARENA(pool,--);
- PR_DELETE(a);
- } while ((a = *ap) != 0);
- } else {
- /* Insert the whole arena chain at the front of the freelist. */
- do {
- PL_MAKE_MEM_NOACCESS((void*)(*ap)->base,
- (*ap)->limit - (*ap)->base);
- ap = &(*ap)->next;
- } while (*ap);
- LockArena();
- *ap = arena_freelist;
- arena_freelist = a;
- head->next = 0;
- UnlockArena();
- }
+ do {
+ PLArena *tmp = a;
+ a = a->next;
+ PL_CLEAR_ARENA(tmp);
+ PL_COUNT_ARENA(pool,--);
+ PR_DELETE(tmp);
+ } while (a);
pool->current = head;
}
@@ -310,7 +205,7 @@
for (a = &pool->first; a; a = a->next) {
if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {
a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
- FreeArenaList(pool, a, PR_FALSE);
+ FreeArenaList(pool, a);
return;
}
}
@@ -318,13 +213,13 @@
PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
{
- FreeArenaList(pool, &pool->first, PR_FALSE);
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/ds/plarena.h
^
|
@@ -13,7 +13,6 @@
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
*/
#include "prtypes.h"
-#include "plarenas.h"
PR_BEGIN_EXTERN_C
@@ -47,6 +46,8 @@
};
#endif
+typedef struct PLArenaPool PLArenaPool;
+
struct PLArenaPool {
PLArena first; /* first arena in pool list */
PLArena *current; /* arena from which to allocate space */
@@ -96,11 +97,11 @@
/* 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))
@@ -225,6 +226,74 @@
(a) = 0; \
PR_END_MACRO
+/*
+** Initialize an arena pool with the given name for debugging and metering,
+** with a minimum gross size per arena of size bytes. The net size per arena
+** is smaller than the gross size by a header of four pointers plus any
+** necessary padding for alignment.
+**
+** Note: choose a gross size that's a power of two to avoid the heap allocator
+** rounding the size up.
+**/
+PR_EXTERN(void) PL_InitArenaPool(
+ PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
+
+/*
+** Finish using arenas, freeing all memory associated with them.
+** NOTE: this function is now a no-op. If you want to free a single
+** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool().
+**/
+PR_EXTERN(void) PL_ArenaFinish(void);
+
+/*
+** Free the arenas in pool. The user may continue to allocate from pool
+** after calling this function. There is no need to call PL_InitArenaPool()
+** again unless PL_FinishArenaPool(pool) has been called.
+**/
+PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
+
+/*
+** Free the arenas in pool and finish using it altogether.
+**/
+PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
+
+/*
+** Compact all of the arenas in a pool so that no space is wasted.
+** NOT IMPLEMENTED. Do not use.
+**/
+PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
+
+/*
+** Friend functions used by the PL_ARENA_*() macros.
+**
+** WARNING: do not call these functions directly. Always use the
+** PL_ARENA_*() macros.
+**/
+PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
+
+PR_EXTERN(void *) PL_ArenaGrow(
+ PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
+
+PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
+
+/*
+** memset contents of all arenas in pool to pattern
+*/
+PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
+
+/*
+** A function like malloc_size() or malloc_usable_size() that measures the
+** size of a heap block.
+*/
+typedef size_t (*PLMallocSizeFn)(const void *ptr);
+
+/*
+** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
+** structure.
+*/
+PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
+ const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
+
#ifdef PL_ARENAMETER
#include <stdio.h>
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/ds/plarenas.h
^
|
@@ -3,79 +3,10 @@
* 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/. */
-#ifndef PLARENAS_H
-#define PLARENAS_H
-
-PR_BEGIN_EXTERN_C
-
-typedef struct PLArenaPool PLArenaPool;
-
-/*
-** Initialize an arena pool with the given name for debugging and metering,
-** with a minimum gross size per arena of size bytes. The net size per arena
-** is smaller than the gross size by a header of four pointers plus any
-** necessary padding for alignment.
-**
-** Note: choose a gross size that's a power of two to avoid the heap allocator
-** rounding the size up.
-**/
-PR_EXTERN(void) PL_InitArenaPool(
- PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
-
-/*
-** Finish using arenas, freeing all memory associated with them.
-**/
-PR_EXTERN(void) PL_ArenaFinish(void);
-
-/*
-** Free the arenas in pool. The user may continue to allocate from pool
-** after calling this function. There is no need to call PL_InitArenaPool()
-** again unless PL_FinishArenaPool(pool) has been called.
-**/
-PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
-
-/*
-** Free the arenas in pool and finish using it altogether.
-**/
-PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
-
-/*
-** Compact all of the arenas in a pool so that no space is wasted.
-** NOT IMPLEMENTED. Do not use.
-**/
-PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
-
/*
-** Friend functions used by the PL_ARENA_*() macros.
-**
-** WARNING: do not call these functions directly. Always use the
-** PL_ARENA_*() macros.
+** PLArena-related declarations used to be split between plarenas.h and
+** plarena.h. That split wasn't useful, so now all the declarations are in
+** plarena.h. However, this file still exists so that any old code that
+** includes it will still work.
**/
-PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
-
-PR_EXTERN(void *) PL_ArenaGrow(
- PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
-
-PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
-
-/*
-** memset contents of all arenas in pool to pattern
-*/
-PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
-
-/*
-** A function like malloc_size() or malloc_usable_size() that measures the
-** size of a heap block.
-*/
-typedef size_t (*PLMallocSizeFn)(const void *ptr);
-
-/*
-** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
-** structure.
-*/
-PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
- const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
-
-PR_END_EXTERN_C
-
-#endif /* PLARENAS_H */
+#include "plarena.h"
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/ds/plvrsion.c
^
|
@@ -74,6 +74,10 @@
#endif /* XP_UNIX */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
{
#ifdef XP_UNIX
@@ -88,6 +92,9 @@
#endif
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic pop
+#endif
/* plvrsion.c */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/libc/src/plvrsion.c
^
|
@@ -74,6 +74,10 @@
#endif /* XP_UNIX */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
{
#ifdef XP_UNIX
@@ -88,6 +92,9 @@
#endif
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic pop
+#endif
/* plvrsion.c */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/libc/src/strcase.c
^
|
@@ -48,8 +48,10 @@
const unsigned char *ua = (const unsigned char *)a;
const unsigned char *ub = (const unsigned char *)b;
- if( ((const char *)0 == a) || (const char *)0 == b )
- return (PRIntn)(a-b);
+ if( (const char *)0 == a )
+ return ((const char *)0 == b) ? 0 : -1;
+ if( (const char *)0 == b )
+ return 1;
while( (uc[*ua] == uc[*ub]) && ('\0' != *a) )
{
@@ -67,8 +69,10 @@
const unsigned char *ua = (const unsigned char *)a;
const unsigned char *ub = (const unsigned char *)b;
- if( ((const char *)0 == a) || (const char *)0 == b )
- return (PRIntn)(a-b);
+ if( (const char *)0 == a )
+ return ((const char *)0 == b) ? 0 : -1;
+ if( (const char *)0 == b )
+ return 1;
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
{
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/libc/src/strcmp.c
^
|
@@ -9,8 +9,10 @@
PR_IMPLEMENT(PRIntn)
PL_strcmp(const char *a, const char *b)
{
- if( ((const char *)0 == a) || (const char *)0 == b )
- return (PRIntn)(a-b);
+ if( (const char *)0 == a )
+ return ((const char *)0 == b) ? 0 : -1;
+ if( (const char *)0 == b )
+ return 1;
return (PRIntn)strcmp(a, b);
}
@@ -18,8 +20,10 @@
PR_IMPLEMENT(PRIntn)
PL_strncmp(const char *a, const char *b, PRUint32 max)
{
- if( ((const char *)0 == a) || (const char *)0 == b )
- return (PRIntn)(a-b);
+ if( (const char *)0 == a )
+ return ((const char *)0 == b) ? 0 : -1;
+ if( (const char *)0 == b )
+ return 1;
return (PRIntn)strncmp(a, b, (size_t)max);
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/lib/prstreams/plvrsion.c
^
|
@@ -74,6 +74,10 @@
#endif /* XP_UNIX */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
{
#ifdef XP_UNIX
@@ -88,6 +92,9 @@
#endif
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic pop
+#endif
/* plvrsion.c */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_freebsd.cfg
^
|
@@ -342,6 +342,52 @@
#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__)
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_freebsd.h
^
|
@@ -29,6 +29,8 @@
#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__)
@@ -228,7 +230,7 @@
#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,
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_linux.cfg
^
|
@@ -498,6 +498,9 @@
#elif defined(__mips__)
+/* For _ABI64 */
+#include <sgidefs.h>
+
#ifdef __MIPSEB__
#define IS_BIG_ENDIAN 1
#undef IS_LITTLE_ENDIAN
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_linux.h
^
|
@@ -67,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
@@ -162,6 +162,16 @@
#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()
@@ -661,7 +671,7 @@
#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,
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_netbsd.h
^
|
@@ -211,7 +211,7 @@
#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,
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_openbsd.h
^
|
@@ -192,7 +192,7 @@
#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,
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_unixos.h
^
|
@@ -302,7 +302,7 @@
#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()
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/md/_win95.h
^
|
@@ -290,6 +290,9 @@
extern PRInt32 _MD_CloseSocket(PROsfd osfd);
#define _MD_CLOSE_SOCKET _MD_CloseSocket
#define _MD_SENDTO _PR_MD_SENDTO
+#ifdef _WIN64
+#define _MD_TCPSENDTO _PR_MD_TCPSENDTO
+#endif
#define _MD_RECVFROM _PR_MD_RECVFROM
#define _MD_SOCKETPAIR(s, type, proto, sv) -1
#define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/pratom.h
^
|
@@ -107,7 +107,9 @@
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
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prenv.h
^
|
@@ -91,6 +91,20 @@
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:
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prinet.h
^
|
@@ -54,7 +54,7 @@
#endif /* XP_UNIX */
#include <netdb.h>
-#if defined(FREEBSD) || defined(BSDI) || defined(QNX)
+#if defined(BSDI) || defined(QNX)
#include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prinit.h
^
|
@@ -31,10 +31,10 @@
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
-#define PR_VERSION "4.10.10"
+#define PR_VERSION "4.17"
#define PR_VMAJOR 4
-#define PR_VMINOR 10
-#define PR_VPATCH 10
+#define PR_VMINOR 17
+#define PR_VPATCH 0
#define PR_BETA PR_FALSE
/*
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prio.h
^
|
@@ -168,7 +168,7 @@
PRIPv6Addr ip; /* the actual 128 bits of address */
PRUint32 scope_id; /* set of interfaces for a scope */
} ipv6;
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN)
struct { /* Unix domain socket address */
PRUint16 family; /* address family (AF_UNIX) */
#ifdef XP_OS2
@@ -196,8 +196,8 @@
PR_SockOpt_Linger, /* linger on close if data present */
PR_SockOpt_Reuseaddr, /* allow local address reuse */
PR_SockOpt_Keepalive, /* keep connections alive */
- PR_SockOpt_RecvBufferSize, /* send buffer size */
- PR_SockOpt_SendBufferSize, /* receive buffer size */
+ PR_SockOpt_RecvBufferSize, /* receive buffer size */
+ PR_SockOpt_SendBufferSize, /* send buffer size */
PR_SockOpt_IpTimeToLive, /* time to live */
PR_SockOpt_IpTypeOfService, /* type of service and precedence */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/private/pprio.h
^
|
@@ -237,6 +237,20 @@
#endif /* WIN32 */
+/* FUNCTION: PR_EXPERIMENTAL_ONLY_IN_4_17_GetOverlappedIOHandle
+** DESCRIPTION:
+** This function will be available only in nspr version 4.17
+** This functionality is only available on windows. Some windows operation use
+** asynchronous (call overlapped) io. One of them is ConnectEx. NSPR uses
+** ConnectEx for enabling TCP Fast Open.
+** This function returns an OVERLAPPED structure associated with ConnectEx call.
+** If ConnectEx has not been called or the io has already finished, the
+** function will return PR_INVALID_ARGUMENT_ERROR.
+** PRFileDesc continues to be owner of the structure and the structure must not
+** be destroyed.
+*/
+NSPR_API(PRStatus) PR_EXPERIMENTAL_ONLY_IN_4_17_GetOverlappedIOHandle(PRFileDesc *fd, void **ol);
+
PR_END_EXTERN_C
#endif /* pprio_h___ */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/private/primpl.h
^
|
@@ -1225,6 +1225,13 @@
const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
#define _PR_MD_SENDTO _MD_SENDTO
+#if defined(_WIN64) && defined(WIN95)
+extern PRInt32 _PR_MD_TCPSENDTO(
+ PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
+ const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
+#define _PR_MD_TCPSENDTO _MD_TCPSENDTO
+#endif
+
extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PROsfd *osfd);
#define _PR_MD_SOCKETPAIR _MD_SOCKETPAIR
@@ -1747,6 +1754,18 @@
* requires knowing the address family of the
* socket, we save the address family here. */
#endif
+
+#if defined(_WIN64)
+ /* This is necessary for TCP Fast Open. TCP Fast Open in windows must
+ * use ConnectEx function which uses OVERLAPPED. TCPSendTo will call
+ * ConnectEx to send fast open data. If ConnectEx returns
+ * ERROR_IO_PENDING we need to save OVERLAPPED structure and we will
+ * use it in ConnectContinue to get the final result of ConnectEx.
+ */
+ PRBool alreadyConnected;
+ PRBool overlappedActive;
+ OVERLAPPED ol;
+#endif
};
#ifdef _WIN64
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prolock.h
^
|
@@ -11,21 +11,21 @@
PR_BEGIN_EXTERN_C
/*
-** A locking mechanism, built on the existing PRLock definiion,
+** A locking mechanism, built on the existing PRLock definition,
** is provided that will permit applications to define a Lock
** Hierarchy (or Lock Ordering) schema. An application designed
** using the Ordered Lock functions will terminate with a
** diagnostic message when a lock inversion condition is
** detected.
**
-** The lock ordering detection is complile-time enabled only. in
+** The lock ordering detection is compile-time enabled only. In
** optimized builds of NSPR, the Ordered Lock functions map
** directly to PRLock functions, providing no lock order
** detection.
**
** The Ordered Lock Facility is compiled in when DEBUG is defined at
-** compile time. Ordered Lock can be forced on in optimized builds by
-** defining FORCE_NSPR_ORDERED_LOCK at compile time. Both the
+** compile-time. Ordered Lock can be forced on in optimized builds by
+** defining FORCE_NSPR_ORDERED_LOCK at compile-time. Both the
** application using Ordered Lock and NSPR must be compiled with the
** facility enabled to achieve the desired results.
**
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/include/prtypes.h
^
|
@@ -231,7 +231,7 @@
** to use <stdint.h>. A patch to do that is in NSPR bug 634793.
*/
-#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__OpenBSD__)
#define PR_ALTERNATE_INT64_TYPEDEF
#endif
@@ -245,16 +245,24 @@
#if PR_BYTES_PER_BYTE == 1
typedef unsigned char PRUint8;
/*
+** There are two scenarios that require us to define PRInt8 as type 'char'.
+** (1)
** Some cfront-based C++ compilers do not like 'signed char' and
** issue the warning message:
** warning: "signed" not implemented (ignored)
** For these compilers, we have to define PRInt8 as plain 'char'.
** Make sure that plain 'char' is indeed signed under these compilers.
+** (2)
+** Mozilla C++ code expects the PRInt{N} and int{N}_t types to match (see bug
+** 634793). If a platform defines int8_t as 'char', but NSPR defines it as
+** 'signed char', it results in a type mismatch.
+** On such platforms we define PRInt8 as 'char' to avoid the mismatch.
*/
-#if (defined(HPUX) && defined(__cplusplus) \
+#if (defined(HPUX) && defined(__cplusplus) /* reason 1*/ \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
- || (defined(SCO) && defined(__cplusplus) \
- && !defined(__GNUC__) && __cplusplus == 1L)
+ || (defined(SCO) && defined(__cplusplus) /* reason 1 */ \
+ && !defined(__GNUC__) && __cplusplus == 1L) \
+ || (defined(__sun) && defined(__cplusplus)) /* reason 2 */
typedef char PRInt8;
#else
typedef signed char PRInt8;
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prio.c
^
|
@@ -119,6 +119,10 @@
fd->methods = methods;
fd->secret->state = _PR_FILEDESC_OPEN;
fd->secret->md.osfd = osfd;
+#if defined(_WIN64)
+ fd->secret->alreadyConnected = PR_FALSE;
+ fd->secret->overlappedActive = PR_FALSE;
+#endif
_PR_MD_INIT_FILEDESC(fd);
} else {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prlayer.c
^
|
@@ -47,7 +47,8 @@
rv = fd->lower->methods->close(fd->lower);
_PR_DestroyIOLayer(fd);
return rv;
- } else if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {
+ }
+ if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {
/*
* lower layers of new style stack
*/
@@ -201,16 +202,16 @@
return NULL;
}
- if (newstyle_stack) {
- newstack->lower = newfd;
- newfd->higher = newstack;
- return newstack;
- } else {
- /* this PR_PushIOLayer call cannot fail */
- rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);
- PR_ASSERT(PR_SUCCESS == rv);
- return newfd; /* that's it */
- }
+ if (newstyle_stack)
+ {
+ newstack->lower = newfd;
+ newfd->higher = newstack;
+ return newstack;
+ }
+ /* this PR_PushIOLayer call cannot fail */
+ rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);
+ PR_ASSERT(PR_SUCCESS == rv);
+ return newfd; /* that's it */
}
static PRStatus PR_CALLBACK pl_DefBind (PRFileDesc *fd, const PRNetAddr *addr)
@@ -326,12 +327,11 @@
(*nd)->higher = newstack;
*nd = newstack;
return nbytes;
- } else {
- /* this PR_PushIOLayer call cannot fail */
- rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);
- PR_ASSERT(PR_SUCCESS == rv);
- return nbytes;
}
+ /* this PR_PushIOLayer call cannot fail */
+ rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);
+ PR_ASSERT(PR_SUCCESS == rv);
+ return nbytes;
}
static PRInt32 PR_CALLBACK pl_DefTransmitfile (
@@ -494,10 +494,9 @@
{
if (NULL == stack)
return PR_FAILURE;
- else {
- PR_DELETE(stack);
- return PR_SUCCESS;
- }
+
+ PR_DELETE(stack);
+ return PR_SUCCESS;
} /* _PR_DestroyIOLayer */
PR_IMPLEMENT(PRStatus) PR_PushIOLayer(
@@ -652,9 +651,11 @@
if ((NULL != names) && (identity < length))
{
/* what we did is still okay */
- memcpy(
- names, identity_cache.name,
- identity_cache.length * sizeof(char*));
+ if (identity_cache.length != 0) {
+ memcpy(
+ names, identity_cache.name,
+ identity_cache.length * sizeof(char*));
+ }
old = identity_cache.name;
identity_cache.name = names;
identity_cache.length = length;
@@ -683,12 +684,17 @@
PR_IMPLEMENT(const char*) PR_GetNameForIdentity(PRDescIdentity ident)
{
+ const char *rv = NULL;
if (!_pr_initialized) _PR_ImplicitInitialization();
- if (PR_TOP_IO_LAYER == ident) return NULL;
+ if ((PR_TOP_IO_LAYER != ident) && (ident >= 0)) {
+ PR_Lock(identity_cache.ml);
+ PR_ASSERT(ident <= identity_cache.ident);
+ rv = (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
+ PR_Unlock(identity_cache.ml);
+ }
- PR_ASSERT(ident <= identity_cache.ident);
- return (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
+ return rv;
} /* PR_GetNameForIdentity */
PR_IMPLEMENT(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd)
@@ -697,8 +703,8 @@
if (PR_IO_LAYER_HEAD == fd->identity) {
PR_ASSERT(NULL != fd->lower);
return fd->lower->identity;
- } else
- return fd->identity;
+ }
+ return fd->identity;
} /* PR_GetLayersIdentity */
PR_IMPLEMENT(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity id)
@@ -706,10 +712,10 @@
PRFileDesc *layer = fd;
if (PR_TOP_IO_LAYER == id) {
- if (PR_IO_LAYER_HEAD == fd->identity)
- return fd->lower;
- else
- return fd;
+ if (PR_IO_LAYER_HEAD == fd->identity) {
+ return fd->lower;
+ }
+ return fd;
}
for (layer = fd; layer != NULL; layer = layer->lower)
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prlog.c
^
|
@@ -238,13 +238,7 @@
}
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
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prmmap.c
^
|
@@ -24,17 +24,16 @@
|| prot == PR_PROT_WRITECOPY);
fmap = PR_NEWZAP(PRFileMap);
if (NULL == fmap) {
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return NULL;
+ PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
+ return NULL;
}
fmap->fd = fd;
fmap->prot = prot;
if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {
- return fmap;
- } else {
+ return fmap;
+ }
PR_DELETE(fmap);
return NULL;
- }
}
PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void)
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prprf.c
^
|
@@ -37,7 +37,7 @@
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;
@@ -461,7 +461,7 @@
if( c == '%' ) continue;
cn = 0;
- while( c && c != '$' ){ /* should imporve error check later */
+ while( c && c != '$' ){ /* should improve error check later */
cn = cn*10 + c - '0';
c = *p++;
}
@@ -697,7 +697,7 @@
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 . */
@@ -745,7 +745,7 @@
if( nas != NULL ){
/* the fmt contains the Numbered Arguments feature */
i = 0;
- while( c && c != '$' ){ /* should imporve error check later */
+ while( c && c != '$' ){ /* should improve error check later */
i = ( i * 10 ) + ( c - '0' );
c = *fmt++;
}
@@ -1060,6 +1060,13 @@
{
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;
@@ -1105,9 +1112,21 @@
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 {
@@ -1210,8 +1229,8 @@
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;
}
@@ -1247,7 +1266,10 @@
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;
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prscanf.c
^
|
@@ -194,7 +194,7 @@
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 @@
GetFloat(ScanfState *state)
{
char buf[FMAX + 1], *p;
- int ch;
+ int ch = 0;
PRBool seenDigit = PR_FALSE;
if (state->width == 0 || state->width > FMAX) {
@@ -409,7 +409,8 @@
ch = GET(state);
if (ch == EOF) {
return NULL;
- } else if (state->assign) {
+ }
+ if (state->assign) {
*cArg++ = ch;
}
}
@@ -602,10 +603,9 @@
if (*cPtr == '\0') {
return EOF;
- } else {
- *((char **) stream) = cPtr + 1;
- return (unsigned char) *cPtr;
}
+ *((char **) stream) = cPtr + 1;
+ return (unsigned char) *cPtr;
}
static void
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/io/prsocket.c
^
|
@@ -7,6 +7,12 @@
#include <string.h>
+#if defined(_WIN64)
+#ifndef SO_UPDATE_CONNECT_CONTEXT
+#define SO_UPDATE_CONNECT_CONTEXT 0x7010
+#endif
+#endif
+
/************************************************************************/
/* These two functions are only used in assertions. */
@@ -298,12 +304,72 @@
if (err != 0) {
_PR_MD_MAP_CONNECT_ERROR(err);
} else {
+#if defined(_WIN64)
+ if (fd->secret->overlappedActive) {
+ PRInt32 rvSent;
+ if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == FALSE) {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("SocketConnectContinue GetOverlappedResult failed %d\n", err));
+ if (err != ERROR_IO_INCOMPLETE) {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ fd->secret->overlappedActive = PR_FALSE;
+ }
+ }
+ }
+ if (err == 0) {
+ PR_SetError(PR_UNKNOWN_ERROR, 0);
+ }
+#else
PR_SetError(PR_UNKNOWN_ERROR, 0);
+#endif
}
return PR_FAILURE;
}
PR_ASSERT(out_flags & PR_POLL_WRITE);
+
+#if defined(_WIN64)
+ if (fd->secret->alreadyConnected) {
+ fd->secret->alreadyConnected = PR_FALSE;
+ }
+ /* TCP Fast Open on Windows must use ConnectEx, which uses overlapped
+ * input/output.
+ * To get result we need to use GetOverlappedResult. */
+ if (fd->secret->overlappedActive) {
+ PR_ASSERT(fd->secret->nonblocking);
+ PRInt32 rvSent;
+ if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) {
+ fd->secret->overlappedActive = PR_FALSE;
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("SocketConnectContinue GetOverlappedResult succeeded\n"));
+ /* When ConnectEx is used, all previously set socket options and
+ * property are not enabled and to enable them
+ * SO_UPDATE_CONNECT_CONTEXT option need to be set. */
+ if (setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0) != 0) {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("SocketConnectContinue setting SO_UPDATE_CONNECT_CONTEXT failed %d\n", err));
+ _PR_MD_MAP_SETSOCKOPT_ERROR(err);
+ return PR_FAILURE;
+ }
+ return PR_SUCCESS;
+ } else {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("SocketConnectContinue GetOverlappedResult failed %d\n", err));
+ if (err != ERROR_IO_INCOMPLETE) {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ fd->secret->overlappedActive = PR_FALSE;
+ return PR_FAILURE;
+ } else {
+ PR_SetError(PR_IN_PROGRESS_ERROR, 0);
+ return PR_FAILURE;
+ }
+ }
+ }
+#endif
+
return PR_SUCCESS;
#elif defined(XP_OS2)
@@ -751,7 +817,7 @@
#endif
count = 0;
- while (amount > 0) {
+ do {
temp = _PR_MD_SENDTO(fd, buf, amount, flags,
addrp, PR_NETADDR_SIZE(addr), timeout);
if (temp < 0) {
@@ -764,10 +830,60 @@
}
buf = (const void*) ((const char*)buf + temp);
amount -= temp;
- }
+ } while (amount > 0);
return count;
}
+#if defined(_WIN64) && defined(WIN95)
+static PRInt32 PR_CALLBACK SocketTCPSendTo(
+ PRFileDesc *fd, const void *buf, PRInt32 amount,
+ PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout)
+{
+ PRInt32 temp, count;
+ const PRNetAddr *addrp = addr;
+#if defined(_PR_INET6)
+ PRNetAddr addrCopy;
+#endif
+ PRThread *me = _PR_MD_CURRENT_THREAD();
+
+ if (_PR_PENDING_INTERRUPT(me)) {
+ me->flags &= ~_PR_INTERRUPT;
+ PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
+ return -1;
+ }
+ if (_PR_IO_PENDING(me)) {
+ PR_SetError(PR_IO_PENDING_ERROR, 0);
+ return -1;
+ }
+
+ PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
+#if defined(_PR_INET6)
+ if (addr->raw.family == PR_AF_INET6) {
+ addrCopy = *addr;
+ addrCopy.raw.family = AF_INET6;
+ addrp = &addrCopy;
+ }
+#endif
+
+ count = 0;
+ while (amount > 0) {
+ temp = _PR_MD_TCPSENDTO(fd, buf, amount, flags,
+ addrp, PR_NETADDR_SIZE(addr), timeout);
+ if (temp < 0) {
+ count = -1;
+ break;
+ }
+ count += temp;
+ if (fd->secret->nonblocking) {
+ break;
+ }
+ buf = (const void*) ((const char*)buf + temp);
+ amount -= temp;
+ }
+ return count;
+}
+#endif
+
static PRInt32 PR_CALLBACK SocketRecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount,
PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
{
@@ -1066,6 +1182,15 @@
PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags)
{
*out_flags = 0;
+
+#if defined(_WIN64)
+ if (in_flags & PR_POLL_WRITE) {
+ if (fd->secret->alreadyConnected) {
+ out_flags = PR_POLL_WRITE;
+ return PR_POLL_WRITE;
+ }
+ }
+#endif
return in_flags;
} /* SocketPoll */
@@ -1090,7 +1215,11 @@
SocketRecv,
SocketSend,
(PRRecvfromFN)_PR_InvalidInt,
+#if defined(_WIN64) && defined(WIN95)
+ SocketTCPSendTo, /* This is for fast open. We imitate Linux interface. */
+#else
(PRSendtoFN)_PR_InvalidInt,
+#endif
SocketPoll,
SocketAcceptRead,
SocketTransmitFile,
@@ -1555,6 +1684,33 @@
fd->secret->md.osfd = handle;
}
+/* Expose OVERLAPPED if present. OVERLAPPED is implemented only on WIN95. */
+PR_IMPLEMENT(PRStatus)
+PR_EXPERIMENTAL_ONLY_IN_4_17_GetOverlappedIOHandle(PRFileDesc *fd, void **ol)
+{
+#if defined(_WIN64) && defined(WIN95)
+ *ol = NULL;
+ if (fd) {
+ fd = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);
+ }
+ if (!fd) {
+ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/unix/unix.c
^
|
@@ -2715,7 +2715,7 @@
/* 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 @@
}
#endif
-#if defined(HAVE_CLOCK_MONOTONIC)
+#if defined(_PR_HAVE_CLOCK_MONOTONIC)
PRIntervalTime _PR_UNIX_GetInterval2()
{
struct timespec time;
@@ -3316,11 +3316,11 @@
return errno;
} else {
return err;
- }
+ }
}
} else {
return ECONNREFUSED;
- }
+ }
#elif defined(UNIXWARE)
/*
* getsockopt() fails with EPIPE, so use getmsg() instead.
@@ -3331,17 +3331,17 @@
rv = getmsg(osfd, NULL, NULL, &flags);
PR_ASSERT(-1 == rv || 0 == rv);
if (-1 == rv && errno != EAGAIN && errno != EWOULDBLOCK) {
- return errno;
+ return errno;
}
- return 0; /* no error */
+ return 0; /* no error */
#else
- int err;
- _PRSockLen_t optlen = sizeof(err);
- if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &optlen) == -1) {
- return errno;
- } else {
- return err;
- }
+ int err;
+ _PRSockLen_t optlen = sizeof(err);
+ if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {
+ return errno;
+ }
+ return err;
+
#endif
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/unix/uxproces.c
^
|
@@ -247,13 +247,14 @@
PR_DELETE(newEnvp);
}
return NULL;
- } else if (0 == process->md.pid) { /* the child process */
- /*
- * If the child process needs to exit, it must call _exit().
- * Do not call exit(), because exit() will flush and close
- * the standard I/O file descriptors, and hence corrupt
- * the parent process's standard I/O data structures.
- */
+ }
+ if (0 == process->md.pid) { /* the child process */
+ /*
+ * If the child process needs to exit, it must call _exit().
+ * Do not call exit(), because exit() will flush and close
+ * the standard I/O file descriptors, and hence corrupt
+ * the parent process's standard I/O data structures.
+ */
#if !defined(NTO) && !defined(SYMBIAN)
if (attr) {
@@ -498,10 +499,9 @@
#endif
if (WIFEXITED(rawExitStatus)) {
return WEXITSTATUS(rawExitStatus);
- } else {
+ }
PR_ASSERT(WIFSIGNALED(rawExitStatus));
return _PR_SIGNALED_EXITSTATUS;
- }
}
static void
@@ -624,8 +624,8 @@
} while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));
#ifdef _PR_SHARE_CLONES
- PR_Unlock(pr_wp.ml);
while ((op = pr_wp.opHead) != NULL) {
+ PR_Unlock(pr_wp.ml);
op->process = ForkAndExec(op->path, op->argv,
op->envp, op->attr);
if (NULL == op->process) {
@@ -639,8 +639,8 @@
}
op->done = PR_TRUE;
PR_NotifyCondVar(op->doneCV);
- PR_Unlock(pr_wp.ml);
}
+ PR_Unlock(pr_wp.ml);
#endif
while (1) {
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/unix/uxshm.c
^
|
@@ -76,8 +76,8 @@
/* copy args to struct */
strcpy( shm->ipcname, ipcname );
- shm->size = size;
- shm->mode = mode;
+ shm->size = size;
+ shm->mode = mode;
shm->flags = flags;
shm->ident = _PR_SHM_IDENT;
@@ -500,30 +500,32 @@
("_md_OpenAnonFileMap(): PR_snprintf(): failed, generating filename"));
goto Finished;
}
-
+
/* create the file */
- osfd = open( genName, (O_CREAT | O_EXCL | O_RDWR), mode );
- if ( -1 == osfd ) {
- if ( EEXIST == errno ) {
- PR_smprintf_free( genName );
- continue; /* name exists, try again */
- } else {
- _PR_MD_MAP_OPEN_ERROR( errno );
- PR_LOG( _pr_shma_lm, PR_LOG_DEBUG,
- ("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d",
- genName, PR_GetOSError()));
- PR_smprintf_free( genName );
- goto Finished;
- }
+ osfd = open(genName, (O_CREAT | O_EXCL | O_RDWR), mode);
+ if (-1 == osfd) {
+ if (EEXIST == errno) {
+ PR_smprintf_free(genName);
+ continue; /* name exists, try again */
+ }
+ _PR_MD_MAP_OPEN_ERROR(errno);
+ PR_LOG(
+ _pr_shma_lm,
+ PR_LOG_DEBUG,
+ ("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d",
+ genName,
+ PR_GetOSError()));
+ PR_smprintf_free(genName);
+ goto Finished;
}
break; /* name generation and open successful, break; */
} /* end for() */
- if ( incr == maxTries ) {
- PR_ASSERT( -1 == osfd );
- PR_ASSERT( EEXIST == errno );
- _PR_MD_MAP_OPEN_ERROR( errno );
- goto Finished;
+ if (incr == maxTries) {
+ PR_ASSERT(-1 == osfd);
+ PR_ASSERT(EEXIST == errno);
+ _PR_MD_MAP_OPEN_ERROR(errno);
+ goto Finished;
}
urc = unlink( genName );
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/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
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/windows/w32poll.c
^
|
@@ -155,7 +155,8 @@
pd->out_flags = 0; /* pre-condition */
/* make sure this is an NSPR supported stack */
bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
- PR_ASSERT(NULL != bottom); /* what to do about that? */
+ /* ignore a socket without PR_NSPR_IO_LAYER available */
+
if ((NULL != bottom)
&& (_PR_FILEDESC_OPEN == bottom->secret->state))
{
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/windows/w95sock.c
^
|
@@ -294,8 +294,7 @@
PRInt32 rv, err;
PRInt32 bytesSent = 0;
- while(bytesSent < amount)
- {
+ do {
while ((rv = sendto( osfd, buf, amount, 0, (struct sockaddr *) addr,
addrlen)) == -1)
{
@@ -327,10 +326,177 @@
return -1;
}
}
- }
+ } while(bytesSent < amount);
return bytesSent;
}
+#if defined(_WIN64)
+
+static PRCallOnceType _pr_has_connectex_once;
+typedef BOOL (PASCAL FAR * _pr_win_connectex_ptr)(_In_ SOCKET s, _In_reads_bytes_(namelen) const struct sockaddr FAR *name, _In_ int namelen, _In_reads_bytes_opt_(dwSendDataLength) PVOID lpSendBuffer, _In_ DWORD dwSendDataLength, _Out_ LPDWORD lpdwBytesSent, _Inout_ LPOVERLAPPED lpOverlapped);
+
+#ifndef WSAID_CONNECTEX
+#define WSAID_CONNECTEX \
+ {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
+#endif
+#ifndef SIO_GET_EXTENSION_FUNCTION_POINTER
+#define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006
+#endif
+#ifndef TCP_FASTOPEN
+#define TCP_FASTOPEN 15
+#endif
+
+#ifndef SO_UPDATE_CONNECT_CONTEXT
+#define SO_UPDATE_CONNECT_CONTEXT 0x7010
+#endif
+
+static _pr_win_connectex_ptr _pr_win_connectex = NULL;
+
+static PRStatus PR_CALLBACK _pr_set_connectex(void)
+{
+ _pr_win_connectex = NULL;
+ SOCKET sock;
+ PRInt32 dwBytes;
+ int rc;
+
+ /* Dummy socket needed for WSAIoctl */
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (sock == INVALID_SOCKET)
+ return PR_SUCCESS;
+
+ GUID guid = WSAID_CONNECTEX;
+ rc = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER,
+ &guid, sizeof(guid),
+ &_pr_win_connectex, sizeof(_pr_win_connectex),
+ &dwBytes, NULL, NULL);
+ if (rc != 0) {
+ _pr_win_connectex = NULL;
+ return PR_SUCCESS;
+ }
+
+ rc = closesocket(sock);
+ return PR_SUCCESS;
+}
+
+PRInt32
+_PR_MD_TCPSENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
+ const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
+{
+ if (PR_CallOnce(&_pr_has_connectex_once, _pr_set_connectex) != PR_SUCCESS) {
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return PR_FAILURE;
+ }
+
+ if (_pr_win_connectex == NULL) {
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return PR_FAILURE;
+ }
+
+ PROsfd osfd = fd->secret->md.osfd;
+ PRInt32 rv, err;
+ PRInt32 bytesSent = 0;
+ DWORD rvSent;
+
+ BOOL option = 1;
+ rv = setsockopt((SOCKET)osfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&option, sizeof(option));
+ if (rv != 0) {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("_PR_MD_TCPSENDTO error set opt TCP_FASTOPEN failed %d\n", err));
+ if (err == WSAENOPROTOOPT) {
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ } else {
+ _PR_MD_MAP_SETSOCKOPT_ERROR(err);
+ }
+ return -1;
+ }
+
+ /* ConnectEx requires the socket to be initially bound. We will use INADDR_ANY. */
+ PRNetAddr bindAddr;
+ memset(&bindAddr, 0, sizeof(bindAddr));
+ bindAddr.raw.family = addr->raw.family;
+
+ rv = bind((SOCKET)osfd, (const struct sockaddr *)&(bindAddr.inet), PR_NETADDR_SIZE(&bindAddr));
+ if (rv != 0) {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("_PR_MD_TCPSENDTO error bind failed %d\n", err));
+ _PR_MD_MAP_SETSOCKOPT_ERROR(err);
+ return -1;
+ }
+
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("_PR_MD_TCPSENDTO calling _pr_win_connectex %d %p\n", amount, (char*)buf));
+
+ rvSent = 0;
+ memset(&fd->secret->ol, 0, sizeof(fd->secret->ol));
+ /* ConnectEx return TRUE on a success and FALSE on an error. */
+ if (_pr_win_connectex( (SOCKET)osfd, (struct sockaddr *) addr,
+ addrlen, buf, amount,
+ &rvSent, &fd->secret->ol) == TRUE) {
+ /* When ConnectEx is used, all previously set socket options and
+ * property are not enabled and to enable them
+ * SO_UPDATE_CONNECT_CONTEXT option need to be set. */
+ rv = setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
+ if (rv != 0) {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("_PR_MD_TCPSENDTO setting SO_UPDATE_CONNECT_CONTEXT failed %d\n", err));
+ _PR_MD_MAP_SETSOCKOPT_ERROR(err);
+ return -1;
+ }
+ /* We imitate Linux here. SendTo will return number of bytes send but
+ * it can not return connection success at the same time, so we return
+ * number of bytes send and "connection success" will be return on the
+ * connectcontinue. */
+ fd->secret->alreadyConnected = PR_TRUE;
+ return rvSent;
+ } else {
+ err = WSAGetLastError();
+ PR_LOG(_pr_io_lm, PR_LOG_MIN,
+ ("_PR_MD_TCPSENDTO error _pr_win_connectex failed %d\n", err));
+ if (err != ERROR_IO_PENDING) {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ return -1;
+ } else if (fd->secret->nonblocking) {
+ /* Remember that overlapped structure is set. We will need to get
+ * the final result of ConnectEx call. */
+ fd->secret->overlappedActive = PR_TRUE;
+
+ /* ConnectEx will copy supplied data to a internal buffer and send
+ * them during Fast Open or after connect. Therefore we can assumed
+ * this data already send. */
+ if (amount > 0) {
+ return amount;
+ }
+
+ _PR_MD_MAP_CONNECT_ERROR(WSAEWOULDBLOCK);
+ return -1;
+ }
+ // err is ERROR_IO_PENDING and socket is blocking, so query
+ // GetOverlappedResult.
+ err = ERROR_IO_INCOMPLETE;
+ while (err == ERROR_IO_INCOMPLETE) {
+ rv = socket_io_wait(osfd, WRITE_FD, timeout);
+ if ( rv < 0 ) {
+ return -1;
+ }
+ rv = GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE);
+ if ( rv == TRUE ) {
+ return rvSent;
+ } else {
+ err = WSAGetLastError();
+ if (err != ERROR_IO_INCOMPLETE) {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ return -1;
+ }
+ }
+ }
+ }
+ return -1;
+}
+#endif
+
PRInt32
_PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout)
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/windows/w95thred.c
^
|
@@ -65,7 +65,7 @@
** 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 @@
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 */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/md/windows/win32_errors.c
^
|
@@ -166,21 +166,26 @@
prError = PR_ADDRESS_IN_USE_ERROR;
break;
case WSAEADDRNOTAVAIL:
+ case ERROR_INVALID_NETNAME:
prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;
break;
case WSAEAFNOSUPPORT:
+ case ERROR_INCORRECT_ADDRESS:
prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
break;
case WSAEALREADY:
+ case ERROR_ALREADY_INITIALIZED:
prError = PR_ALREADY_INITIATED_ERROR;
break;
case WSAEBADF:
prError = PR_BAD_DESCRIPTOR_ERROR;
break;
case WSAECONNABORTED:
+ case ERROR_CONNECTION_ABORTED:
prError = PR_CONNECT_ABORTED_ERROR;
break;
case WSAECONNREFUSED:
+ case ERROR_CONNECTION_REFUSED:
prError = PR_CONNECT_REFUSED_ERROR;
break;
case WSAECONNRESET:
@@ -193,6 +198,7 @@
prError = PR_ACCESS_FAULT_ERROR;
break;
case WSAEHOSTUNREACH:
+ case ERROR_HOST_UNREACHABLE:
prError = PR_HOST_UNREACHABLE_ERROR;
break;
case WSAEINVAL:
@@ -208,12 +214,14 @@
prError = PR_BUFFER_OVERFLOW_ERROR;
break;
case WSAENETDOWN:
+ case ERROR_NO_NETWORK:
prError = PR_NETWORK_DOWN_ERROR;
break;
case WSAENETRESET:
prError = PR_CONNECT_ABORTED_ERROR;
break;
case WSAENETUNREACH:
+ case ERROR_NETWORK_UNREACHABLE:
prError = PR_NETWORK_UNREACHABLE_ERROR;
break;
case WSAENOBUFS:
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/praton.c
^
|
@@ -177,19 +177,21 @@
case 2: /*%< a.b -- 8.24 bits */
if (val > 0xffffffU)
return (0);
- val |= parts[0] << 24;
+ val |= (unsigned int)parts[0] << 24;
break;
case 3: /*%< a.b.c -- 8.8.16 bits */
if (val > 0xffffU)
return (0);
- val |= (parts[0] << 24) | (parts[1] << 16);
+ val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16);
break;
case 4: /*%< a.b.c.d -- 8.8.8.8 bits */
if (val > 0xffU)
return (0);
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ val |= ((unsigned int)parts[0] << 24) |
+ ((unsigned int)parts[1] << 16) |
+ ((unsigned int)parts[2] << 8);
break;
}
*addr = PR_htonl(val);
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prenv.c
^
|
@@ -4,10 +4,12 @@
* 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>
@@ -17,6 +19,11 @@
#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()
@@ -63,6 +70,34 @@
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;
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prlong.c
^
|
@@ -5,10 +5,10 @@
#include "prlong.h"
-static PRInt64 ll_zero = LL_INIT( 0x00000000,0x00000000 );
-static PRInt64 ll_maxint = LL_INIT( 0x7fffffff, 0xffffffff );
-static PRInt64 ll_minint = LL_INIT( 0x80000000, 0x00000000 );
-static PRUint64 ll_maxuint = LL_INIT( 0xffffffff, 0xffffffff );
+static PRInt64 ll_zero = PR_INT64(0x0000000000000000);
+static PRInt64 ll_maxint = PR_INT64(0x7fffffffffffffff);
+static PRInt64 ll_minint = PR_INT64(0x8000000000000000);
+static PRUint64 ll_maxuint = PR_UINT64(0xffffffffffffffff);
PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; }
PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; }
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prnetdb.c
^
|
@@ -63,8 +63,7 @@
#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
@@ -1406,7 +1405,7 @@
PRStatus rv = PR_SUCCESS;
if (!_pr_initialized) _PR_ImplicitInitialization();
- if (val != PR_IpAddrNull) memset(addr, 0, sizeof(addr->inet));
+ if (val != PR_IpAddrNull) memset(addr, 0, sizeof(*addr));
addr->inet.family = AF_INET;
addr->inet.port = htons(port);
switch (val)
@@ -1484,18 +1483,20 @@
if (val == PR_IpAddrAny) {
if (_PR_IN6_IS_ADDR_UNSPECIFIED((PRIPv6Addr *)&addr->ipv6.ip)) {
return PR_TRUE;
- } else if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
- && _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
- == htonl(INADDR_ANY)) {
- return PR_TRUE;
+ }
+ if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
+ && _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
+ == htonl(INADDR_ANY)) {
+ return PR_TRUE;
}
} else if (val == PR_IpAddrLoopback) {
if (_PR_IN6_IS_ADDR_LOOPBACK((PRIPv6Addr *)&addr->ipv6.ip)) {
return PR_TRUE;
- } else if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
- && _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
- == htonl(INADDR_LOOPBACK)) {
- return PR_TRUE;
+ }
+ if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
+ && _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
+ == htonl(INADDR_LOOPBACK)) {
+ return PR_TRUE;
}
} else if (val == PR_IpAddrV4Mapped
&& _PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)) {
@@ -1505,8 +1506,9 @@
if (addr->raw.family == AF_INET) {
if (val == PR_IpAddrAny && addr->inet.ip == htonl(INADDR_ANY)) {
return PR_TRUE;
- } else if (val == PR_IpAddrLoopback
- && addr->inet.ip == htonl(INADDR_LOOPBACK)) {
+ }
+ if (val == PR_IpAddrLoopback
+ && addr->inet.ip == htonl(INADDR_LOOPBACK)) {
return PR_TRUE;
}
}
@@ -1778,18 +1780,12 @@
#ifdef IS_BIG_ENDIAN
return n;
#else
- PRUint64 tmp;
PRUint32 hi, lo;
- LL_L2UI(lo, n);
- LL_SHR(tmp, n, 32);
- LL_L2UI(hi, tmp);
+ lo = (PRUint32)n;
+ hi = (PRUint32)(n >> 32);
hi = PR_ntohl(hi);
lo = PR_ntohl(lo);
- LL_UI2L(n, lo);
- LL_SHL(n, n, 32);
- LL_UI2L(tmp, hi);
- LL_ADD(n, n, tmp);
- return n;
+ return ((PRUint64)lo << 32) + (PRUint64)hi;
#endif
} /* ntohll */
@@ -1798,18 +1794,12 @@
#ifdef IS_BIG_ENDIAN
return n;
#else
- PRUint64 tmp;
PRUint32 hi, lo;
- LL_L2UI(lo, n);
- LL_SHR(tmp, n, 32);
- LL_L2UI(hi, tmp);
+ lo = (PRUint32)n;
+ hi = (PRUint32)(n >> 32);
hi = htonl(hi);
lo = htonl(lo);
- LL_UI2L(n, lo);
- LL_SHL(n, n, 32);
- LL_UI2L(tmp, hi);
- LL_ADD(n, n, tmp);
- return n;
+ return ((PRUint64)lo << 32) + (PRUint64)hi;
#endif
} /* htonll */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prtime.c
^
|
@@ -279,8 +279,7 @@
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
return 1;
- else
- return 0;
+ return 0;
}
/*
@@ -495,6 +494,20 @@
#define MT_safe_localtime localtime_r
+#elif defined(_MSC_VER)
+
+/* Visual C++ has had localtime_s() since Visual C++ 2005. */
+
+static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
+{
+ errno_t err = localtime_s(result, clock);
+ if (err != 0) {
+ errno = err;
+ return NULL;
+ }
+ return result;
+}
+
#else
#define HAVE_LOCALTIME_MONITOR 1 /* We use 'monitor' to serialize our calls
@@ -580,6 +593,7 @@
PRTimeParameters retVal;
struct tm localTime;
+ struct tm *localTimeResult;
time_t secs;
PRTime secs64;
PRInt64 usecPerSec;
@@ -606,7 +620,12 @@
*/
secs = 86400L;
- (void) MT_safe_localtime(&secs, &localTime);
+ localTimeResult = MT_safe_localtime(&secs, &localTime);
+ PR_ASSERT(localTimeResult != NULL);
+ if (localTimeResult == NULL) {
+ /* Shouldn't happen. Use safe fallback for optimized builds. */
+ return PR_GMTParameters(gmt);
+ }
/* GMT is 00:00:00, 2nd of Jan. */
@@ -957,6 +976,7 @@
int hour = -1;
int min = -1;
int sec = -1;
+ struct tm *localTimeResult;
const char *rest = string;
@@ -1215,7 +1235,7 @@
if ((end - rest) > 2)
/* it is [0-9][0-9][0-9]+: */
break;
- else if ((end - rest) == 2)
+ if ((end - rest) == 2)
tmp_hour = ((rest[0]-'0')*10 +
(rest[1]-'0'));
else
@@ -1230,12 +1250,12 @@
if (end == rest)
/* no digits after first colon? */
break;
- else if ((end - rest) > 2)
+ if ((end - rest) > 2)
/* it is [0-9][0-9][0-9]+: */
break;
- else if ((end - rest) == 2)
+ if ((end - rest) == 2)
tmp_min = ((rest[0]-'0')*10 +
- (rest[1]-'0'));
+ (rest[1]-'0'));
else
tmp_min = (rest[0]-'0');
@@ -1253,7 +1273,7 @@
else if ((end - rest) > 2)
/* it is [0-9][0-9][0-9]+: */
break;
- else if ((end - rest) == 2)
+ if ((end - rest) == 2)
tmp_sec = ((rest[0]-'0')*10 +
(rest[1]-'0'));
else
@@ -1287,7 +1307,7 @@
rest = end;
break;
}
- else if ((*end == '/' || *end == '-') &&
+ if ((*end == '/' || *end == '-') &&
end[1] >= '0' && end[1] <= '9')
{
/* Perhaps this is 6/16/95, 16/6/95, 6-16-95, or 16-6-95
@@ -1618,7 +1638,11 @@
zone_offset for the date we are parsing is the same as
the zone offset on 00:00:00 2 Jan 1970 GMT. */
secs = 86400;
- (void) MT_safe_localtime(&secs, &localTime);
+ localTimeResult = MT_safe_localtime(&secs, &localTime);
+ PR_ASSERT(localTimeResult != NULL);
+ if (localTimeResult == NULL) {
+ return PR_FAILURE;
+ }
zone_offset = localTime.tm_min
+ 60 * localTime.tm_hour
+ 1440 * (localTime.tm_mday - 2);
@@ -1989,24 +2013,22 @@
dayOfWeek = time->tm_wday - firstDayOfWeek;
if (dayOfWeek < 0)
dayOfWeek += 7;
-
- dayOfYear = time->tm_yday - dayOfWeek;
+ dayOfYear = time->tm_yday - dayOfWeek;
if( dayOfYear <= 0 )
{
/* If dayOfYear is <= 0, it is in the first partial week of the year. */
return 0;
}
- else
- {
- /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there
- * are any days left over ( dayOfYear % 7 ). Because we are only counting to
- * the first day of the week containing the given time, rather than to the
- * actual day representing the given time, any days in week 0 will be "absorbed"
- * as extra days in the given week.
- */
- return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 );
- }
+
+ /* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there
+ * are any days left over ( dayOfYear % 7 ). Because we are only counting to
+ * the first day of the week containing the given time, rather than to the
+ * actual day representing the given time, any days in week 0 will be "absorbed"
+ * as extra days in the given week.
+ */
+ return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 );
+
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prtpool.c
^
|
@@ -281,8 +281,8 @@
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;
@@ -862,16 +862,16 @@
if ((rv == PR_FAILURE) && ((err = PR_GetError()) == PR_IN_PROGRESS_ERROR)){
/* connection pending */
return(queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_CONNECT));
- } else {
- /*
- * connection succeeded or failed; add to jobq right away
- */
- if (rv == PR_FAILURE)
- iod->error = err;
- else
- iod->error = 0;
- return(PR_QueueJob(tpool, fn, arg, joinable));
}
+ /*
+ * connection succeeded or failed; add to jobq right away
+ */
+ if (rv == PR_FAILURE)
+ iod->error = err;
+ else
+ iod->error = 0;
+ return(PR_QueueJob(tpool, fn, arg, joinable));
+
}
/* queue a job, when a timer expires */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/misc/prtrace.c
^
|
@@ -657,14 +657,8 @@
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,
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/nspr.def
^
|
@@ -455,3 +455,10 @@
;+ 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;
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/prvrsion.c
^
|
@@ -74,6 +74,10 @@
#endif /* XP_UNIX */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
{
#ifdef XP_UNIX
@@ -88,6 +92,9 @@
#endif
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
+#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
+#pragma GCC diagnostic pop
+#endif
/* prvrsion.c */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/pthreads/ptio.c
^
|
@@ -164,6 +164,9 @@
#ifndef TCP_CORK
#define TCP_CORK 3
#endif
+#ifndef MSG_FASTOPEN
+#define MSG_FASTOPEN 0x20000000
+#endif
#endif
#ifdef _PR_IPV6_V6ONLY_PROBE
@@ -821,7 +824,7 @@
op->arg3.amount -= bytes; /* and reduce the required count */
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
}
- else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
+ if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
{
op->result.code = -1;
return PR_TRUE;
@@ -850,7 +853,7 @@
op->arg3.amount -= bytes; /* and reduce the required count */
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
}
- else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
+ if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
{
op->result.code = -1;
return PR_TRUE;
@@ -892,7 +895,7 @@
op->arg3.amount -= iov_index; /* and array length */
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
}
- else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
+ if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
{
op->result.code = -1;
return PR_TRUE;
@@ -915,7 +918,7 @@
op->arg3.amount -= bytes; /* and reduce the required count */
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
}
- else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
+ if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
{
op->result.code = -1;
return PR_TRUE;
@@ -1542,23 +1545,26 @@
pt_SockLen addr_len;
const PRNetAddr *addrp = addr;
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
- PRUint16 md_af = addr->raw.family;
PRNetAddr addrCopy;
#endif
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ PRUint16 md_af = addr->raw.family;
+#endif
if (pt_TestAbort()) return PR_FAILURE;
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
addr_len = PR_NETADDR_SIZE(addr);
-#if defined(_PR_INET6)
- if (addr->raw.family == PR_AF_INET6) {
- md_af = AF_INET6;
-#ifndef _PR_HAVE_SOCKADDR_LEN
- addrCopy = *addr;
- addrCopy.raw.family = AF_INET6;
- addrp = &addrCopy;
+#ifdef _PR_INET6
+ if (addr->raw.family == PR_AF_INET6) {
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ md_af = AF_INET6;
+#else
+ addrCopy = *addr;
+ addrCopy.raw.family = AF_INET6;
+ addrp = &addrCopy;
#endif
- }
+ }
#endif
#ifdef _PR_HAVE_SOCKADDR_LEN
@@ -1732,9 +1738,11 @@
pt_SockLen addr_len;
const PRNetAddr *addrp = addr;
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
- PRUint16 md_af = addr->raw.family;
PRNetAddr addrCopy;
#endif
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ PRUint16 md_af = addr->raw.family;
+#endif
if (pt_TestAbort()) return PR_FAILURE;
@@ -1749,15 +1757,16 @@
}
}
-#if defined(_PR_INET6)
- if (addr->raw.family == PR_AF_INET6) {
- md_af = AF_INET6;
-#ifndef _PR_HAVE_SOCKADDR_LEN
- addrCopy = *addr;
- addrCopy.raw.family = AF_INET6;
- addrp = &addrCopy;
+#ifdef _PR_INET6
+ if (addr->raw.family == PR_AF_INET6) {
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ md_af = AF_INET6;
+#else
+ addrCopy = *addr;
+ addrCopy.raw.family = AF_INET6;
+ addrp = &addrCopy;
#endif
- }
+ }
#endif
addr_len = PR_NETADDR_SIZE(addr);
@@ -1989,22 +1998,25 @@
pt_SockLen addr_len;
const PRNetAddr *addrp = addr;
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
- PRUint16 md_af = addr->raw.family;
PRNetAddr addrCopy;
#endif
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ PRUint16 md_af = addr->raw.family;
+#endif
if (pt_TestAbort()) return bytes;
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
-#if defined(_PR_INET6)
- if (addr->raw.family == PR_AF_INET6) {
- md_af = AF_INET6;
-#ifndef _PR_HAVE_SOCKADDR_LEN
- addrCopy = *addr;
- addrCopy.raw.family = AF_INET6;
- addrp = &addrCopy;
+#ifdef _PR_INET6
+ if (addr->raw.family == PR_AF_INET6) {
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ md_af = AF_INET6;
+#else
+ addrCopy = *addr;
+ addrCopy.raw.family = AF_INET6;
+ addrp = &addrCopy;
#endif
- }
+ }
#endif
addr_len = PR_NETADDR_SIZE(addr);
@@ -2044,6 +2056,101 @@
return bytes;
} /* pt_SendTo */
+#if defined(LINUX) || defined(DARWIN)
+/* Linux uses SendTo to send data during TCP Fast Open. OSX uses connectx, but
+ * we will make it imitate the Linux's interface. */
+static PRInt32 pt_TCP_SendTo(
+ PRFileDesc *fd, const void *buf,
+ PRInt32 amount, PRIntn flags, const PRNetAddr *addr,
+ PRIntervalTime timeout)
+{
+#if defined(LINUX) || HAS_CONNECTX
+ PRInt32 syserrno, bytes = -1;
+ PRBool fNeedContinue = PR_FALSE;
+ pt_SockLen addr_len;
+ const PRNetAddr *addrp = addr;
+#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
+ PRNetAddr addrCopy;
+#endif
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ PRUint16 md_af = addr->raw.family;
+#endif
+
+ if (pt_TestAbort()) return bytes;
+
+ PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
+ addr_len = PR_NETADDR_SIZE(addr);
+#if defined(_PR_INET6)
+ if (addr->raw.family == PR_AF_INET6) {
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ md_af = AF_INET6;
+#else
+ /* If _PR_INET6 is defined and it is PR_AF_INET6 we set family
+ * to AF_INET6. */
+ addrCopy = *addr;
+ addrCopy.raw.family = AF_INET6;
+ addrp = &addrCopy;
+#endif
+ }
+#endif
+
+#ifdef _PR_HAVE_SOCKADDR_LEN
+ /* if _PR_HAVE_SOCKADDR_LEN is defined and it is PR_AF_INET6 we set family
+ * to AF_INET6 and we set address length. */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/src/pthreads/ptsynch.c
^
|
@@ -55,12 +55,11 @@
rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr);
PR_ASSERT(0 == rv);
-#ifdef LINUX
-#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
+#if (defined(LINUX) && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
+ (defined(FREEBSD) && __FreeBSD_version > 700055)
rv = pthread_mutexattr_settype(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP);
PR_ASSERT(0 == rv);
#endif
-#endif
rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);
PR_ASSERT(0 == rv);
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/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.
@@ -1733,7 +1737,7 @@
{
PRThread *thread;
size_t nameLen;
- int result;
+ int result = 0;
if (!name) {
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
@@ -1751,8 +1755,10 @@
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
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/tests/accept.c
^
|
@@ -143,12 +143,13 @@
if (action != CLIENT_TIMEOUT_SEND) {
if ((rv = PR_Send(sock, buf, CLIENT_DATA,
0, timeoutTime))< 0) {
- if (!debug_mode)
+ if (!debug_mode) {
failed_already=1;
- else
- PR_fprintf(output,
+ } else {
+ PR_fprintf(output,
"client: unable to send to server (%d, %ld, %ld)\n",
CLIENT_DATA, rv, PR_GetError());
+ }
goto ErrorExit;
}
} else {
@@ -200,8 +201,9 @@
continue;
}
failed_already=1;
- if (debug_mode)
+ if (debug_mode) {
PR_fprintf(output,"accept: ERROR - PR_Bind failed\n");
+ }
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/tests/alarm.c
^
|
@@ -411,15 +411,15 @@
PRUint32 overhead, usecs;
PRIntervalTime predicted, timein, timeout, ticks;
- if (debug_mode)
- printf("Testing %s ...", msg);
+ if (debug_mode)
+ printf("Testing %s ...", msg);
timein = PR_IntervalNow();
predicted = func(loops);
timeout = PR_IntervalNow();
- if (debug_mode)
- printf(" done\n");
+ if (debug_mode)
+ printf(" done\n");
ticks = timeout - timein;
usecs = PR_IntervalToMicroseconds(ticks);
@@ -491,17 +491,17 @@
for (cpu = 1; cpu <= cpus; ++cpu)
{
- if (debug_mode)
+ if (debug_mode)
printf("\nAlarm: Using %d CPU(s)\n", cpu);
- PR_SetConcurrency(cpu);
-
- /* some basic time test */
- (void)TimeThis("ConditionNotify", ConditionNotify, loops);
- (void)TimeThis("ConditionTimeout", ConditionTimeout, loops);
- (void)TimeThis("Alarms1", Alarms1, loops);
- (void)TimeThis("Alarms2", Alarms2, loops);
- (void)TimeThis("Alarms3", Alarms3, loops);
+ PR_SetConcurrency(cpu);
+
+ /* some basic time test */
+ (void)TimeThis("ConditionNotify", ConditionNotify, loops);
+ (void)TimeThis("ConditionTimeout", ConditionTimeout, loops);
+ (void)TimeThis("Alarms1", Alarms1, loops);
+ (void)TimeThis("Alarms2", Alarms2, loops);
+ (void)TimeThis("Alarms3", Alarms3, loops);
}
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/tests/env.c
^
|
@@ -18,6 +18,7 @@
PRIntn debug = 0;
PRIntn verbose = 0;
+PRIntn secure = 0;
PRBool failedAlready = PR_FALSE;
#define ENVNAME "NSPR_ENVIRONMENT_TEST_VARIABLE"
@@ -43,7 +44,7 @@
{ /* 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)))
{
@@ -56,6 +57,15 @@
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;
}
@@ -113,6 +123,32 @@
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() */
{
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/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 @@
break;
case FAIL:
printf ("FAIL\n");
+ failed_already = 1;
break;
default:
break;
@@ -246,21 +248,32 @@
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 @@
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 @@
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 @@
PR_Cleanup();
- return 0;
+ return failed_already;
}
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/tests/sockopt.c
^
|
@@ -43,8 +43,8 @@
"PR_SockOpt_Linger", /* linger on close if data present */
"PR_SockOpt_Reuseaddr", /* allow local address reuse */
"PR_SockOpt_Keepalive", /* keep connections alive */
- "PR_SockOpt_RecvBufferSize", /* send buffer size */
- "PR_SockOpt_SendBufferSize", /* receive buffer size */
+ "PR_SockOpt_RecvBufferSize", /* receive buffer size */
+ "PR_SockOpt_SendBufferSize", /* send buffer size */
"PR_SockOpt_IpTimeToLive", /* time to live */
"PR_SockOpt_IpTypeOfService", /* type of service and precedence */
|
[-]
[+]
|
Changed |
_service:tar_git:nspr-4.17.tar.gz/nspr/pr/tests/vercheck.c
^
|
@@ -22,8 +22,7 @@
/*
* 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, 4.10.6, 4.10.7, 4.10.8, 4.10.9 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[] = {
@@ -40,6 +39,8 @@
"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.12", "4.13", "4.14", "4.15",
+ "4.16",
PR_VERSION
};
@@ -55,8 +56,8 @@
"3.0", "3.0.1",
"3.1", "3.1.1", "3.1.2", "3.1.3",
"3.5", "3.5.1",
- "4.10.11",
- "4.11", "4.11.1",
+ "4.17.1",
+ "4.18", "4.18.1",
"10.0", "11.1", "12.14.20"
};
|