[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[257] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-10-30 09:08:21
|
Revision: 257 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=257&view=rev Author: nickols_k Date: 2012-10-30 09:08:10 +0000 (Tue, 30 Oct 2012) Log Message: ----------- add some antiviral protection Modified Paths: -------------- mplayerxp/configure mplayerxp/mplayer.c mplayerxp/osdep/mp_malloc.c mplayerxp/osdep/mplib.h Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-10-30 07:35:22 UTC (rev 256) +++ mplayerxp/configure 2012-10-30 09:08:10 UTC (rev 257) @@ -416,6 +416,22 @@ def_asmalign='#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\n\t"' fi +# find pagesize on this system +echocheck "VM pagesize is" +cat > $TMPC << EOF +#include <stdio.h> +#include <unistd.h> +int main(void) { printf("%i\n",getpagesize()); } +EOF +syspagesize="no" +cc_check && syspagesize="yes" +if enabled syspagesize ; then +vm_pagesize=`$TMPO` +else +vm_pagesize="1" +fi +echores "$vm_pagesize" + check_func3 _ISOC9X_SOURCE math.h lrint -lm print_config HAVE_ mp_config.h mp_config.mak lrint @@ -826,6 +842,14 @@ /* ASMALIGN */ $def_asmalign +/* Physical size of page on this system */ +#define __VM_PAGE_SIZE__ $vm_pagesize +#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) +#define __PAGE_ALIGNED__ __attribute__ ((aligned (__VM_PAGE_SIZE__))) +#else +#define __PAGE_ALIGNED__ +#endif + /* Define this if your system has the llrint in "math.h" header file */ #ifndef HAVE_LLRINT #define HAVE_LLRINT 1 @@ -874,6 +898,7 @@ /* libvo options */ $def_fbdev_nocopy + /* Defined to some form of __attribute__ ((...)) if the compiler supports a different, more efficient calling convention. */ #if defined ( __USE_FASTCALL ) Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-10-30 07:35:22 UTC (rev 256) +++ mplayerxp/mplayer.c 2012-10-30 09:08:10 UTC (rev 257) @@ -70,6 +70,7 @@ /************************************************************************** Private data **************************************************************************/ +static volatile char antiviral_hole1[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; #if defined( ARCH_X86 ) || defined(ARCH_X86_64) typedef struct x86_features_s { int simd; @@ -129,6 +130,7 @@ }priv_t; mp_conf_t mp_conf; +static volatile char antiviral_hole2[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; mp_data_t*mp_data=NULL; /************************************************************************** @@ -138,6 +140,7 @@ ao_data_t* ao_data=NULL; vo_data_t* vo_data=NULL; +static volatile char antiviral_hole3[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; /************************************************************************** Config file @@ -167,6 +170,21 @@ #include "fifo.h" /**************************************************************************/ +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); + if(verbose) { + if(rc) + MSG_ERR("*** Error! Cannot initialize antiviral protection: '%s' ***!\n",strerror(errno)); + else + MSG_OK("*** Antiviral protection was inited ***!!!\n"); + } + return rc; +} + static void mpxp_init_structs(void) { mp_data=mp_malloc(sizeof(mp_data_t)); memset(mp_data,0,sizeof(mp_data_t)); @@ -2339,6 +2357,8 @@ * MAIN MPLAYERXP FUNCTION !!! * \******************************************/ int main(int argc,char* argv[], char *envp[]){ + mpxp_init_antiviral_protection(1); + int i; stream_t* stream=NULL; int stream_dump_type=0; input_state_t input_state = { 0, 0, 0 }; @@ -2350,7 +2370,6 @@ int eof=0; osd_args_t osd = { 100, 9 }; int rtc_fd=-1; - int i; int forced_subs_only=0; seek_args_t seek_args = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; Modified: mplayerxp/osdep/mp_malloc.c =================================================================== --- mplayerxp/osdep/mp_malloc.c 2012-10-30 07:35:22 UTC (rev 256) +++ mplayerxp/osdep/mp_malloc.c 2012-10-30 09:08:10 UTC (rev 257) @@ -211,3 +211,8 @@ ,priv->stat_num_allocs); return priv->stat_num_allocs; } + +int __FASTCALL__ mp_mprotect(const any_t* addr,size_t len,int flags) +{ + return mprotect(addr,len,flags); +} Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-10-30 07:35:22 UTC (rev 256) +++ mplayerxp/osdep/mplib.h 2012-10-30 09:08:10 UTC (rev 257) @@ -9,6 +9,7 @@ #ifndef __MPLIB_H_INCLUDED__ #define __MPLIB_H_INCLUDED__ 1 #include <stddef.h> +#include <sys/mman.h> #include "mp_config.h" extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; @@ -49,4 +50,6 @@ extern void __FASTCALL__ mp_free(any_t*__ptr); 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); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |