[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[267] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-10-31 14:29:45
|
Revision: 267 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=267&view=rev Author: nickols_k Date: 2012-10-31 14:29:38 +0000 (Wed, 31 Oct 2012) Log Message: ----------- add test for antiviral protection Modified Paths: -------------- mplayerxp/cfg-mplayer.h mplayerxp/mplayer.c mplayerxp/mplayer.h mplayerxp/osdep/mp_malloc.c mplayerxp/osdep/mplib.h Modified: mplayerxp/cfg-mplayer.h =================================================================== --- mplayerxp/cfg-mplayer.h 2012-10-31 14:00:16 UTC (rev 266) +++ mplayerxp/cfg-mplayer.h 2012-10-31 14:29:38 UTC (rev 267) @@ -46,6 +46,7 @@ {"autoq", &mp_conf.autoq, CONF_TYPE_INT, CONF_RANGE, 0, 100, "dynamically changes the level of postprocessing depending on spare CPU time available"}, {"speed", &mp_conf.playbackspeed_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 100.0, "sets playback speed factor"}, {"benchmark", &mp_conf.benchmark, CONF_TYPE_FLAG, 0, 0, 1, "performs benchmarking to estimate performance of MPlayerXP"}, + {"test-av", &mp_conf.test_av, CONF_TYPE_FLAG, 0, 0, 1, "test antiviral protection of MPlayerXP"}, {NULL, NULL, 0, 0, 0, 0, NULL}, }; Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-10-31 14:00:16 UTC (rev 266) +++ mplayerxp/mplayer.c 2012-10-31 14:29:38 UTC (rev 267) @@ -173,9 +173,9 @@ static int mpxp_init_antiviral_protection(int verbose) { int rc; - rc=mp_mprotect(antiviral_hole1,sizeof(antiviral_hole1),PROT_NONE); - rc|=mp_mprotect(antiviral_hole2,sizeof(antiviral_hole2),PROT_NONE); - rc|=mp_mprotect(antiviral_hole3,sizeof(antiviral_hole3),PROT_NONE); + rc=mp_mprotect(antiviral_hole1,sizeof(antiviral_hole1),MP_PROT_NONE); + rc|=mp_mprotect(antiviral_hole2,sizeof(antiviral_hole2),MP_PROT_NONE); + rc|=mp_mprotect(antiviral_hole3,sizeof(antiviral_hole3),MP_PROT_NONE); if(verbose) { if(rc) MSG_ERR("*** Error! Cannot initialize antiviral protection: '%s' ***!\n",strerror(errno)); @@ -185,6 +185,15 @@ return rc; } +static int mpxp_test_antiviral_protection(int verbose) +{ + int rc; + if(verbose) MSG_INFO("Right now MPlayerXP should make coredump!\n"); + rc=antiviral_hole1[0]|antiviral_hole2[0]|antiviral_hole2[0]; + MSG_ERR("Antiviral protection of MPlayerXP doesn't work!"); + return rc; +} + static void mpxp_init_structs(void) { mp_data=mp_mallocz(sizeof(mp_data_t)); mp_data->seek_time=-1; @@ -2402,6 +2411,10 @@ "Note! Single-thread mode is not longer supported by MPlayerXP\n"); exit_player(MSGTR_Exit_quit); } + if(mp_conf.test_av) { + mpxp_test_antiviral_protection(mp_conf.verbose); + exit_player("Bad test of antiviral protection"); + } xp_num_cpu=get_number_cpu(); #if defined( ARCH_X86 ) || defined(ARCH_X86_64) Modified: mplayerxp/mplayer.h =================================================================== --- mplayerxp/mplayer.h 2012-10-31 14:00:16 UTC (rev 266) +++ mplayerxp/mplayer.h 2012-10-31 14:29:38 UTC (rev 267) @@ -12,6 +12,7 @@ int use_stdin; int slave_mode; uint32_t msg_filter; + int test_av; // XP-core int xp; /* XP-mode */ int gomp; /* currently it's experimental feature */ Modified: mplayerxp/osdep/mp_malloc.c =================================================================== --- mplayerxp/osdep/mp_malloc.c 2012-10-31 14:00:16 UTC (rev 266) +++ mplayerxp/osdep/mp_malloc.c 2012-10-31 14:29:38 UTC (rev 267) @@ -115,7 +115,7 @@ typedef struct priv_s { unsigned rnd_limit; unsigned every_nth_call; - unsigned flags; + enum mp_malloc_e flags; // statistics unsigned long long int total_calls; unsigned long long int num_allocs; @@ -126,7 +126,7 @@ }priv_t; static priv_t* priv; -void mp_init_malloc(unsigned rnd_limit,unsigned every_nth_call,unsigned flags) +void mp_init_malloc(unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags) { if(!priv) priv=malloc(sizeof(priv_t)); memset(priv,0,sizeof(priv_t)); @@ -214,7 +214,7 @@ return priv->stat_num_allocs; } -int __FASTCALL__ mp_mprotect(const any_t* addr,size_t len,int flags) +int __FASTCALL__ mp_mprotect(const any_t* addr,size_t len,enum mp_prot_e flags) { return mprotect(addr,len,flags); } Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-10-31 14:00:16 UTC (rev 266) +++ mplayerxp/osdep/mplib.h 2012-10-31 14:29:38 UTC (rev 267) @@ -36,13 +36,13 @@ * @note Pseudo-randomizing memory objects makes memory * exploits harder */ -enum { +enum mp_malloc_e { MPA_FLG_RANDOMIZER = 0x00000000, MPA_FLG_BOUNDS_CHECK = 0x00000001, MPA_FLG_BEFORE_CHECK = 0x00000002, MPA_FLG_BACKTRACE = 0x00000004 }; -extern void __FASTCALL__ mp_init_malloc(unsigned rnd_limit,unsigned every_nth_call,unsigned flags); +extern void __FASTCALL__ mp_init_malloc(unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags); extern void __FASTCALL__ mp_uninit_malloc(int verbose); extern void __FASTCALL__ mp_open_malloc_stat(void); @@ -57,5 +57,11 @@ extern char * __FASTCALL__ mp_strdup(const char *src); /* flags: PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC */ -extern int __FASTCALL__ mp_mprotect(const any_t* addr,size_t len,int flags); +enum mp_prot_e { + MP_PROT_READ =0x1, /* Page can be read. */ + MP_PROT_WRITE =0x2, /* Page can be written. */ + MP_PROT_EXEC =0x4, /* Page can be executed. */ + MP_PROT_NONE =0x0, /* Page can not be accessed. */ +}; +extern int __FASTCALL__ mp_mprotect(const any_t* addr,size_t len,enum mp_prot_e flags); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |