atari:xbios: We align pointer on a 256-byte boundary, so we need to allocate enough to avoid potential out of bounds access SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Fri, 22 Sep 2017 18:31:25 +0200
branchSDL-1.2
changeset 11521e597fa82484b
parent 11389 2c67e7e5a106
child 11544 15a09f7c6ed8
atari:xbios: We align pointer on a 256-byte boundary, so we need to allocate enough to avoid potential out of bounds access
src/video/xbios/SDL_xbios_f30.c
src/video/xbios/SDL_xbios_st.c
     1.1 --- a/src/video/xbios/SDL_xbios_f30.c	Mon Aug 28 09:38:12 2017 -0700
     1.2 +++ b/src/video/xbios/SDL_xbios_f30.c	Fri Sep 22 18:31:25 2017 +0200
     1.3 @@ -282,13 +282,13 @@
     1.4  	Uint32 tmp;
     1.5  
     1.6  	for (i=0; i<num_buffers; i++) {
     1.7 -		XBIOS_screensmem[i] = Atari_SysMalloc(bufsize, MX_STRAM);
     1.8 +		XBIOS_screensmem[i] = Atari_SysMalloc(bufsize+256, MX_STRAM);
     1.9  
    1.10  		if (XBIOS_screensmem[i]==NULL) {
    1.11  			SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
    1.12  			return (0);
    1.13  		}
    1.14 -		SDL_memset(XBIOS_screensmem[i], 0, bufsize);
    1.15 +		SDL_memset(XBIOS_screensmem[i], 0, bufsize+256);
    1.16  
    1.17  		/* Align on 256byte boundary and map to Supervidel memory */
    1.18  		tmp = ( (Uint32) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL;
     2.1 --- a/src/video/xbios/SDL_xbios_st.c	Mon Aug 28 09:38:12 2017 -0700
     2.2 +++ b/src/video/xbios/SDL_xbios_st.c	Fri Sep 22 18:31:25 2017 +0200
     2.3 @@ -157,13 +157,13 @@
     2.4  	int i;
     2.5  
     2.6  	for (i=0; i<num_buffers; i++) {
     2.7 -		XBIOS_screensmem[i] = Atari_SysMalloc(bufsize, MX_STRAM);
     2.8 +		XBIOS_screensmem[i] = Atari_SysMalloc(bufsize+256, MX_STRAM);
     2.9  
    2.10  		if (XBIOS_screensmem[i]==NULL) {
    2.11  			SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
    2.12  			return (0);
    2.13  		}
    2.14 -		SDL_memset(XBIOS_screensmem[i], 0, bufsize);
    2.15 +		SDL_memset(XBIOS_screensmem[i], 0, bufsize+256);
    2.16  
    2.17  		XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL);
    2.18  	}