X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl.h;h=46ce72b89c7ae3d206e492f9dd052a60bd5624a1;hb=1dd9311ab0a647f516752dd7368cf0b3f3ae13a4;hp=f43316861d585400cb4ed55da7ee49a34a8b03af;hpb=2868e2bb2b1cf521f022c2f26ac0adccd8f45749;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perl.h b/perl.h index f433168..46ce72b 100644 --- a/perl.h +++ b/perl.h @@ -73,12 +73,23 @@ /* Use the reentrant APIs like localtime_r and getpwent_r */ /* Win32 has naturally threadsafe libraries, no need to use any _r variants. */ -#if defined(USE_ITHREADS) && !defined(USE_REENTRANT_API) && !defined(NETWARE) && !defined(WIN32) && !defined(__APPLE__) +#if defined(USE_ITHREADS) && !defined(USE_REENTRANT_API) && !defined(NETWARE) && !defined(WIN32) && !defined(PERL_DARWIN) # define USE_REENTRANT_API #endif /* <--- here ends the logic shared by perl.h and makedef.pl */ +/* + * PERL_DARWIN for MacOSX (__APPLE__ exists but is not officially sanctioned) + * (The -DPERL_DARWIN comes from the hints/darwin.sh.) + * __bsdi__ for BSD/OS + */ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(PERL_DARWIN) || defined(__bsdi__) || defined(BSD41) || defined(BSD42) || defined(BSD43) || defined(BSD44) +# ifndef BSDish +# define BSDish +# endif +#endif + #ifdef PERL_IMPLICIT_CONTEXT # ifndef MULTIPLICITY # define MULTIPLICITY @@ -470,28 +481,42 @@ int usleep(unsigned int); # else # define EMBEDMYMALLOC /* for compatibility */ # endif -START_EXTERN_C -Malloc_t Perl_malloc (MEM_SIZE nbytes); -Malloc_t Perl_calloc (MEM_SIZE elements, MEM_SIZE size); -Malloc_t Perl_realloc (Malloc_t where, MEM_SIZE nbytes); -/* 'mfree' rather than 'free', since there is already a 'perl_free' - * that causes clashes with case-insensitive linkers */ -Free_t Perl_mfree (Malloc_t where); -END_EXTERN_C - -typedef struct perl_mstats perl_mstats_t; # define safemalloc Perl_malloc # define safecalloc Perl_calloc # define saferealloc Perl_realloc # define safefree Perl_mfree +# define CHECK_MALLOC_TOO_LATE_FOR_(code) STMT_START { \ + if (!PL_tainting && MallocCfg_ptr[MallocCfg_cfg_env_read]) \ + code; \ + } STMT_END +# define CHECK_MALLOC_TOO_LATE_FOR(ch) \ + CHECK_MALLOC_TOO_LATE_FOR_(MALLOC_TOO_LATE_FOR(ch)) +# define panic_write2(s) write(2, s, strlen(s)) +# define CHECK_MALLOC_TAINT(newval) \ + CHECK_MALLOC_TOO_LATE_FOR_( \ + if (newval) { \ + panic_write2("panic: tainting with $ENV{PERL_MALLOC_OPT}\n");\ + exit(1); }) +# define MALLOC_CHECK_TAINT(argc,argv,env) STMT_START { \ + if (doing_taint(argc,argv,env)) { \ + MallocCfg_ptr[MallocCfg_skip_cfg_env] = 1; \ + }} STMT_END; #else /* MYMALLOC */ # define safemalloc safesysmalloc # define safecalloc safesyscalloc # define saferealloc safesysrealloc # define safefree safesysfree +# define CHECK_MALLOC_TOO_LATE_FOR(ch) ((void)0) +# define CHECK_MALLOC_TAINT(newval) ((void)0) +# define MALLOC_CHECK_TAINT(argc,argv,env) #endif /* MYMALLOC */ +#define TOO_LATE_FOR_(ch,s) Perl_croak(aTHX_ "Too late for \"-%c\" option%s", (char)(ch), s) +#define TOO_LATE_FOR(ch) TOO_LATE_FOR_(ch, "") +#define MALLOC_TOO_LATE_FOR(ch) TOO_LATE_FOR_(ch, " with $ENV{PERL_MALLOC_OPT}") +#define MALLOC_CHECK_TAINT2(argc,argv) MALLOC_CHECK_TAINT(argc,argv,NULL) + #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr) #define strchr index #define strrchr rindex @@ -647,9 +672,12 @@ typedef struct perl_mstats perl_mstats_t; # define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */ #endif -/* In Tru64 use the 4.4BSD struct msghdr, not the 4.3 one */ -#if defined(__osf__) && defined(__alpha) && !defined(_SOCKADDR_LEN) -# define _SOCKADDR_LEN +/* In Tru64 use the 4.4BSD struct msghdr, not the 4.3 one. + * This is important for using IPv6. + * For OSF/1 3.2, however, defining _SOCKADDR_LEN would be + * a bad idea since it breaks send() and recv(). */ +#if defined(__osf__) && defined(__alpha) && !defined(_SOCKADDR_LEN) && !defined(DEC_OSF1_3_X) +# define _SOCKADDR_LEN #endif #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* VMS/WIN32 handle sockets via vmsish.h/win32.h */ @@ -1665,17 +1693,10 @@ int isnan(double d); #endif -struct perl_mstats { - UV *nfree; - UV *ntotal; - IV topbucket, topbucket_ev, topbucket_odd, totfree, total, total_chain; - IV total_sbrk, sbrks, sbrk_good, sbrk_slack, start_slack, sbrked_remains; - IV minbucket; - /* Level 1 info */ - UV *bucket_mem_size; - UV *bucket_available_size; - UV nbuckets; -}; +#ifdef MYMALLOC +# include "malloc_ctl.h" +#endif + struct RExC_state_t; typedef MEM_SIZE STRLEN; @@ -1917,18 +1938,17 @@ typedef struct clone_params CLONE_PARAMS; # define PERL_FPU_INIT fpsetmask(0); # else # if defined(SIGFPE) && defined(SIG_IGN) -# define PERL_FPU_INIT signal(SIGFPE, SIG_IGN); +# define PERL_FPU_INIT PL_sigfpe_saved = signal(SIGFPE, SIG_IGN); +# define PERL_FPU_PRE_EXEC { Sigsave_t xfpe; rsignal_save(SIGFPE, PL_sigfpe_saved, &xfpe); +# define PERL_FPU_POST_EXEC rsignal_restore(SIGFPE, &xfpe); } # else # define PERL_FPU_INIT # endif # endif #endif - -#ifdef JPL - /* E.g. JPL needs to operate on a copy of the real environment. - * JDK 1.2 and 1.3 seem to get upset if the original environment - * is diddled with. */ -# define NEED_ENVIRON_DUP_FOR_MODIFY +#ifndef PERL_FPU_PRE_EXEC +# define PERL_FPU_PRE_EXEC { +# define PERL_FPU_POST_EXEC } #endif #ifndef PERL_SYS_INIT3 @@ -2238,6 +2258,17 @@ typedef struct crypt_data { /* straight from /usr/include/crypt.h */ #if !defined(OS2) && !defined(MACOS_TRADITIONAL) # include "iperlsys.h" #endif + +/* [perl #22371] Algorimic Complexity Attack on Perl 5.6.1, 5.8.0. + * Note that the USE_HASH_SEED and USE_HASH_SEED_EXPLICIT are *NOT* + * defined by Configure, despite their names being similar to the + * other defines like USE_ITHREADS. Configure in fact knows nothing + * about the randomised hashes. Therefore to enable/disable the hash + * randomisation defines use the Configure -Accflags=... instead. */ +#if !defined(NO_HASH_SEED) && !defined(USE_HASH_SEED) && !defined(USE_HASH_SEED_EXPLICIT) +# define USE_HASH_SEED +#endif + #include "regexp.h" #include "sv.h" #include "util.h" @@ -2522,8 +2553,8 @@ Gid_t getegid (void); # define DEBUG_v_TEST DEBUG_v_TEST_ # define DEBUG_C_TEST DEBUG_C_TEST_ -# define DEB(a) a -# define DEBUG(a) if (PL_debug) a +# define PERL_DEB(a) a +# define PERL_DEBUG(a) if (PL_debug) a # define DEBUG_p(a) if (DEBUG_p_TEST) a # define DEBUG_s(a) if (DEBUG_s_TEST) a # define DEBUG_l(a) if (DEBUG_l_TEST) a @@ -2585,8 +2616,8 @@ Gid_t getegid (void); # define DEBUG_v_TEST (0) # define DEBUG_C_TEST (0) -# define DEB(a) -# define DEBUG(a) +# define PERL_DEB(a) +# define PERL_DEBUG(a) # define DEBUG_p(a) # define DEBUG_s(a) # define DEBUG_l(a) @@ -2611,6 +2642,13 @@ Gid_t getegid (void); #endif /* DEBUGGING */ +#define DEBUG_SCOPE(where) \ + DEBUG_l(WITH_THR(Perl_deb(aTHX_ "%s scope %ld at %s:%d\n", \ + where, PL_scopestack_ix, __FILE__, __LINE__))); + + + + /* These constants should be used in preference to raw characters * when using magic. Note that some perl guts still assume * certain character properties of these constants, namely that @@ -2666,14 +2704,14 @@ Gid_t getegid (void); #ifndef assert /* might have been included somehow */ #ifdef DEBUGGING -#define assert(what) DEB( { \ +#define assert(what) PERL_DEB( { \ if (!(what)) { \ Perl_croak(aTHX_ "Assertion " STRINGIFY(what) " failed: file \"%s\", line %d", \ __FILE__, __LINE__); \ PerlProc_exit(1); \ }}) #else -#define assert(what) DEB( { \ +#define assert(what) PERL_DEB( { \ if (!(what)) { \ Perl_croak(aTHX_ "Assertion failed: file \"%s\", line %d", \ __FILE__, __LINE__); \ @@ -2909,13 +2947,13 @@ typedef OP* (CPERLscope(*PPADDR_t)[]) (pTHX); /* NeXT has problems with crt0.o globals */ #if defined(__DYNAMIC__) && \ - (defined(NeXT) || defined(__NeXT__) || defined(__APPLE__)) + (defined(NeXT) || defined(__NeXT__) || defined(PERL_DARWIN)) # if defined(NeXT) || defined(__NeXT) # include # define environ (*environ_pointer) EXT char *** environ_pointer; # else -# if defined(__APPLE__) && defined(PERL_CORE) +# if defined(PERL_DARWIN) && defined(PERL_CORE) # include /* for the env array */ # define environ (*_NSGetEnviron()) # endif @@ -4330,7 +4368,6 @@ extern void moncontrol(int); HAS_UALARM HAS_USLEEP - HAS_NANOSLEEP HAS_SETITIMER HAS_GETITIMER