From: Nicholas Clark Date: Tue, 23 Mar 2004 22:35:09 +0000 (+0000) Subject: Make usemallocwrap a Configure-time question. Default is yes for X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9df442c23deb1b1ba2f163eb54deeb4fe82ea80c;p=p5sagit%2Fp5-mst-13.2.git Make usemallocwrap a Configure-time question. Default is yes for usedevel, no otherwise, but I'm expecting hints files on known good platforms to override this. (and known bad) Demonstration hints file for darwin. p4raw-id: //depot/perl@22571 --- diff --git a/Configure b/Configure index b58dd15..072afbf 100755 --- a/Configure +++ b/Configure @@ -942,6 +942,7 @@ freetype='' mallocobj='' mallocsrc='' malloctype='' +usemallocwrap='' usemymalloc='' installman1dir='' man1dir='' @@ -6258,6 +6259,26 @@ EOM ;; esac +: determine whether to use malloc wrapping +echo " " +case "$usemallocwrap" in +[yY]*|true|$define) dflt='y' ;; +[nN]*|false|$undef) dflt='n' ;; +*) case "$usedevel" in + [yY]*|true|$define) dflt='y' ;; + *) dflt='n' ;; + esac + ;; +esac +rp="Do you wish to wrap malloc calls to protect against potential overflows?" +. ./myread +usemallocwrap="$ans" +case "$ans" in +y*|true) + usemallocwrap="$define" ;; +*) + usemallocwrap="$undef" ;; +esac : determine which malloc to compile in echo " " @@ -21143,6 +21164,7 @@ make_set_make='$make_set_make' mallocobj='$mallocobj' mallocsrc='$mallocsrc' malloctype='$malloctype' +usemallocwrap='$usemallocwrap' man1dir='$man1dir' man1direxp='$man1direxp' man1ext='$man1ext' diff --git a/config_h.SH b/config_h.SH index 9dd1c9c..18697fb 100644 --- a/config_h.SH +++ b/config_h.SH @@ -2186,6 +2186,11 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$d_mymalloc MYMALLOC /**/ +/* PERL_MALLOC_WRAP: + * This symbol, if defined, indicates that we'd like malloc wrap checks. + */ +#$usemallocwrap PERL_MALLOC_WRAP /**/ + /* CAN_PROTOTYPE: * If defined, this macro indicates that the C compiler can handle * function prototypes. diff --git a/hints/darwin.sh b/hints/darwin.sh index 1d27f33..e117a26 100644 --- a/hints/darwin.sh +++ b/hints/darwin.sh @@ -183,6 +183,11 @@ EOCBU # vfork works usevfork='true'; +# malloc wrap works +case "$usemallocwrap" in +'') usemallocwrap='define' ;; +esac + # our malloc works (but allow users to override) case "$usemymalloc" in '') usemymalloc='n' ;; diff --git a/perl.h b/perl.h index d2fa70f..3d86da4 100644 --- a/perl.h +++ b/perl.h @@ -1767,10 +1767,6 @@ typedef struct ptr_tbl_ent PTR_TBL_ENT_t; typedef struct ptr_tbl PTR_TBL_t; typedef struct clone_params CLONE_PARAMS; -#ifndef NO_PERL_MALLOC_WRAP -#define PERL_MALLOC_WRAP /* We'd like malloc wrap checks. */ -#endif - #include "handy.h" #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_RAWIO)