Skip to content

Commit

Permalink
Bug 1244062, NSPR_4_12_BETA2, and Bug 1245053, NSS_3_23_BETA2
Browse files Browse the repository at this point in the history
  • Loading branch information
kaie committed Feb 2, 2016
1 parent d72adc2 commit d3fd404
Show file tree
Hide file tree
Showing 82 changed files with 343 additions and 158 deletions.
2 changes: 1 addition & 1 deletion nsprpub/TAG-INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NSPR_4_11_RTM
NSPR_4_12_BETA2
1 change: 0 additions & 1 deletion nsprpub/config/prdepend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
*/

#error "Do not include this header file."

8 changes: 2 additions & 6 deletions nsprpub/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2488,7 +2488,7 @@ test -n "$target_alias" &&
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=
Expand Down Expand Up @@ -7048,10 +7048,6 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
PR_MD_ASFILES=os_Linux_ppc.s
fi
;;
m68k)
CFLAGS="$CFLAGS -m68020-60"
CXXFLAGS="$CXXFLAGS -m68020-60"
;;
esac
;;
Expand Down Expand Up @@ -7894,7 +7890,7 @@ fi
_SAVE_LIBS="$LIBS"
LIBS="$LIBS $OS_LIBS"
for ac_func in dladdr gettid lchown setpriority strerror syscall
for ac_func in dladdr gettid lchown setpriority strerror syscall secure_getenv __secure_getenv
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Expand Down
9 changes: 3 additions & 6 deletions nsprpub/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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=
Expand Down Expand Up @@ -1856,10 +1856,6 @@ tools are selected during the Xcode/Developer Tools installation.])
PR_MD_ASFILES=os_Linux_ppc.s
fi
;;
m68k)
CFLAGS="$CFLAGS -m68020-60"
CXXFLAGS="$CXXFLAGS -m68020-60"
;;
esac
;;

Expand Down Expand Up @@ -2543,7 +2539,8 @@ dnl ========================================================
AC_PROG_GCC_TRADITIONAL
_SAVE_LIBS="$LIBS"
LIBS="$LIBS $OS_LIBS"
AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall)
AC_CHECK_FUNCS(dladdr gettid lchown setpriority strerror syscall dnl
secure_getenv __secure_getenv)
LIBS="$_SAVE_LIBS"

dnl ========================================================
Expand Down
46 changes: 46 additions & 0 deletions nsprpub/pr/include/md/_freebsd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 3 additions & 1 deletion nsprpub/pr/include/md/_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -228,7 +230,7 @@ extern void _MD_EarlyInit(void);

#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_INTERVAL_USE_GTOD
#define _PR_HAVE_CLOCK_MONOTONIC

/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/md/_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ extern void _MD_EarlyInit(void);

#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define HAVE_CLOCK_MONOTONIC
#define _PR_HAVE_CLOCK_MONOTONIC

/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/md/_netbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extern void _MD_EarlyInit(void);

#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_INTERVAL_USE_GTOD
#define _PR_HAVE_CLOCK_MONOTONIC

/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/md/_openbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ struct _MDCPU {

#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_INTERVAL_USE_GTOD
#define _PR_HAVE_CLOCK_MONOTONIC

/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/md/_unixos.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
#endif

#ifdef HAVE_CLOCK_MONOTONIC
#ifdef _PR_HAVE_CLOCK_MONOTONIC
extern PRIntervalTime _PR_UNIX_GetInterval2(void);
extern PRIntervalTime _PR_UNIX_TicksPerSecond2(void);
#define _MD_INTERVAL_INIT()
Expand Down
14 changes: 14 additions & 0 deletions nsprpub/pr/include/prenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ PR_BEGIN_EXTERN_C
*/
NSPR_API(char*) PR_GetEnv(const char *var);

/*
** PR_GetEnvSecure() -- get a security-sensitive environment variable
**
** Description:
**
** PR_GetEnvSecure() is similar to PR_GetEnv(), but it returns NULL if
** the program was run with elevated privilege (e.g., setuid or setgid
** on Unix). This can be used for cases like log file paths which
** could otherwise be used for privilege escalation. Note that some
** platforms may have platform-specific privilege elevation mechanisms
** not recognized by this function; see the implementation for details.
*/
NSPR_API(char*) PR_GetEnvSecure(const char *var);

/*
** PR_SetEnv() -- set, unset or change an environment variable
**
Expand Down
6 changes: 3 additions & 3 deletions nsprpub/pr/include/prinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.11"
#define PR_VERSION "4.12 Beta"
#define PR_VMAJOR 4
#define PR_VMINOR 11
#define PR_VMINOR 12
#define PR_VPATCH 0
#define PR_BETA PR_FALSE
#define PR_BETA PR_TRUE

/*
** PRVersionCheck
Expand Down
8 changes: 1 addition & 7 deletions nsprpub/pr/src/io/prlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,7 @@ void _PR_InitLog(void)
}
PR_SetLogBuffering(isSync ? 0 : bufSize);

#ifdef XP_UNIX
if ((getuid() != geteuid()) || (getgid() != getegid())) {
return;
}
#endif /* XP_UNIX */

ev = PR_GetEnv("NSPR_LOG_FILE");
ev = PR_GetEnvSecure("NSPR_LOG_FILE");
if (ev && ev[0]) {
if (!PR_SetLogFile(ev)) {
#ifdef XP_PC
Expand Down
34 changes: 28 additions & 6 deletions nsprpub/pr/src/io/prprf.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct SprintfStateStr {

char *base;
char *cur;
PRUint32 maxlen;
PRUint32 maxlen; /* Must not exceed PR_INT32_MAX. */

int (*func)(void *arg, const char *sp, PRUint32 len);
void *arg;
Expand Down Expand Up @@ -697,7 +697,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
char *hexp;
int rv, i;
struct NumArg* nas = NULL;
struct NumArg* nap;
struct NumArg* nap = NULL;
struct NumArg nasArray[ NAS_DEFAULT_NUM ];
char pattern[20];
const char* dolPt = NULL; /* in "%4$.2f", dolPt will point to . */
Expand Down Expand Up @@ -1060,6 +1060,13 @@ static int FuncStuff(SprintfState *ss, const char *sp, PRUint32 len)
{
int rv;

/*
** We will add len to ss->maxlen at the end of the function. First check
** if ss->maxlen + len would overflow or be greater than PR_INT32_MAX.
*/
if (PR_UINT32_MAX - ss->maxlen < len || ss->maxlen + len > PR_INT32_MAX) {
return -1;
}
rv = (*ss->func)(ss->arg, sp, len);
if (rv < 0) {
return rv;
Expand Down Expand Up @@ -1105,9 +1112,21 @@ static int GrowStuff(SprintfState *ss, const char *sp, PRUint32 len)
PRUint32 newlen;

off = ss->cur - ss->base;
if (PR_UINT32_MAX - len < off) {
/* off + len would be too big. */
return -1;
}
if (off + len >= ss->maxlen) {
/* Grow the buffer */
newlen = ss->maxlen + ((len > 32) ? len : 32);
PRUint32 increment = (len > 32) ? len : 32;
if (PR_UINT32_MAX - ss->maxlen < increment) {
/* ss->maxlen + increment would overflow. */
return -1;
}
newlen = ss->maxlen + increment;
if (newlen > PR_INT32_MAX) {
return -1;
}
if (ss->base) {
newbase = (char*) PR_REALLOC(ss->base, newlen);
} else {
Expand Down Expand Up @@ -1210,8 +1229,8 @@ PR_IMPLEMENT(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen,const char *fmt,
SprintfState ss;
PRUint32 n;

PR_ASSERT((PRInt32)outlen > 0);
if ((PRInt32)outlen <= 0) {
PR_ASSERT(outlen != 0 && outlen <= PR_INT32_MAX);
if (outlen == 0 || outlen > PR_INT32_MAX) {
return 0;
}

Expand Down Expand Up @@ -1247,7 +1266,10 @@ PR_IMPLEMENT(char *) PR_vsprintf_append(char *last, const char *fmt, va_list ap)

ss.stuff = GrowStuff;
if (last) {
int lastlen = strlen(last);
size_t lastlen = strlen(last);
if (lastlen > PR_INT32_MAX) {
return 0;
}
ss.base = last;
ss.cur = last + lastlen;
ss.maxlen = lastlen;
Expand Down
4 changes: 2 additions & 2 deletions nsprpub/pr/src/io/prscanf.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static PRStatus
GetInt(ScanfState *state, int code)
{
char buf[FMAX + 1], *p;
int ch;
int ch = 0;
static const char digits[] = "0123456789abcdefABCDEF";
PRBool seenDigit = PR_FALSE;
int base;
Expand Down Expand Up @@ -304,7 +304,7 @@ static PRStatus
GetFloat(ScanfState *state)
{
char buf[FMAX + 1], *p;
int ch;
int ch = 0;
PRBool seenDigit = PR_FALSE;

if (state->width == 0 || state->width > FMAX) {
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/src/md/unix/unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -3040,7 +3040,7 @@ PRIntervalTime _PR_UNIX_TicksPerSecond()
}
#endif

#if defined(HAVE_CLOCK_MONOTONIC)
#if defined(_PR_HAVE_CLOCK_MONOTONIC)
PRIntervalTime _PR_UNIX_GetInterval2()
{
struct timespec time;
Expand Down
7 changes: 6 additions & 1 deletion nsprpub/pr/src/md/windows/w95thred.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,19 @@ _PR_MD_INIT_THREAD(PRThread *thread)
** suspending). Therefore, get a real handle from
** the pseudo handle via DuplicateHandle(...)
*/
DuplicateHandle(
BOOL ok = DuplicateHandle(
GetCurrentProcess(), /* Process of source handle */
GetCurrentThread(), /* Pseudo Handle to dup */
GetCurrentProcess(), /* Process of handle */
&(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 */
Expand Down
Loading

0 comments on commit d3fd404

Please sign in to comment.