diff --git a/source/vid_mgl.c b/source/vid_mgl.c index a907d58..5814935 100644 --- a/source/vid_mgl.c +++ b/source/vid_mgl.c @@ -601,7 +601,7 @@ void VID_InitMGLFull (HINSTANCE hInstance) modelist[curmode].type = MS_FULLSCREEN; modelist[curmode].width = xRes; modelist[curmode].height = yRes; - sprintf (modelist[curmode].modedesc, "%dx%d", xRes, yRes); + snprintf (modelist[curmode].modedesc, sizeof(modelist[curmode].modedesc), "%dx%d", xRes, yRes); if (m[i] == grVGA_320x200x256) modelist[curmode].mode13 = 1; @@ -623,7 +623,7 @@ void VID_InitMGLFull (HINSTANCE hInstance) modelist[MODE_FULLSCREEN_DEFAULT].stretched = 1; modelist[MODE_FULLSCREEN_DEFAULT].width >>= 1; modelist[MODE_FULLSCREEN_DEFAULT].height >>= 1; - sprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, "%dx%d", + snprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, sizeof(modelist[MODE_FULLSCREEN_DEFAULT].modedesc), "%dx%d", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height); } @@ -851,7 +851,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%ldx%ld", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc),"%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight); // if the width is more than twice the height, reduce it by half because this @@ -862,7 +862,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) { modelist[nummodes].width >>= 1; modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", modelist[nummodes].width, modelist[nummodes].height); } @@ -930,7 +930,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%ldx%ld", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc),"%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight); // if the width is more than twice the height, reduce it by half because this @@ -941,7 +941,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) { modelist[nummodes].width >>= 1; modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", modelist[nummodes].width, modelist[nummodes].height); } @@ -1014,7 +1014,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%ldx%ld", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight); // we only want the lowest-bpp version of each mode @@ -1086,7 +1086,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[istretch].width >>= 1; modelist[istretch].height >>= 1; modelist[istretch].stretched = 1; - sprintf (modelist[istretch].modedesc, "%dx%d", + snprintf (modelist[istretch].modedesc, sizeof(modelist[istretch].modedesc),"%dx%d", modelist[istretch].width, modelist[istretch].height); } } @@ -1160,7 +1160,7 @@ void VID_CheckModedescFixup (int mode) /* y = (int)vid_config_y.value; CVAR_FIXME */ y = (int)vid_config_y->value; - sprintf (modelist[mode].modedesc, "%dx%d", x, y); + snprintf (modelist[mode].modedesc, sizeof(modelist[mode].modedesc), "%dx%d", x, y); modelist[mode].width = x; modelist[mode].height = y; } @@ -1238,15 +1238,15 @@ char *VID_GetModeDescription2 (int mode) if (modelist[mode].type == MS_FULLSCREEN) { - sprintf(pinfo,"%s fullscreen", pv->modedesc); + snprintf(pinfo,sizeof(pinfo),"%s fullscreen", pv->modedesc); } else if (modelist[mode].type == MS_FULLDIB) { - sprintf(pinfo,"%s fullscreen", pv->modedesc); + snprintf(pinfo,sizeof(pinfo),"%s fullscreen", pv->modedesc); } else { - sprintf(pinfo, "%s windowed", pv->modedesc); + snprintf(pinfo,sizeof(pinfo), "%s windowed", pv->modedesc); } return pinfo; @@ -1268,16 +1268,16 @@ char *VID_GetExtModeDescription (int mode) pv = VID_GetModePtr (mode); if (modelist[mode].type == MS_FULLSCREEN) { - sprintf(pinfo,"%s fullscreen %s",pv->modedesc, + snprintf(pinfo, sizeof(pinfo), "%s fullscreen %s",pv->modedesc, MGL_modeDriverName(pv->modenum)); } else if (modelist[mode].type == MS_FULLDIB) { - sprintf(pinfo,"%s fullscreen DIB", pv->modedesc); + snprintf(pinfo, sizeof(pinfo), "%s fullscreen DIB", pv->modedesc); } else { - sprintf(pinfo, "%s windowed", pv->modedesc); + snprintf(pinfo, sizeof(pinfo), "%s windowed", pv->modedesc); } return pinfo; @@ -3401,7 +3401,7 @@ void VID_MenuDraw (void) // line cursor if (vid_testingmode) { - sprintf (temp, "TESTING %s", + snprintf (temp, sizeof(temp), "TESTING %s", modedescs[vid_line].desc); M_Print (13*8, 36 + MODE_AREA_HEIGHT * 8 + 8*4, temp); M_Print (9*8, 36 + MODE_AREA_HEIGHT * 8 + 8*6, @@ -3417,7 +3417,7 @@ void VID_MenuDraw (void) if (ptr) { - sprintf (temp, "D to set default: %s", ptr); + snprintf (temp, sizeof(temp), "D to set default: %s", ptr); M_Print (2*8, 36 + MODE_AREA_HEIGHT * 8 + 8*5, temp); } @@ -3427,7 +3427,7 @@ void VID_MenuDraw (void) if (ptr) { - sprintf (temp, "Current default: %s", ptr); + snprintf (temp, sizeof(temp), "Current default: %s", ptr); M_Print (3*8, 36 + MODE_AREA_HEIGHT * 8 + 8*6, temp); } diff --git a/source/vid_wgl.c b/source/vid_wgl.c index 55b692d..5d3b34b 100644 --- a/source/vid_wgl.c +++ b/source/vid_wgl.c @@ -921,7 +921,7 @@ byte scantokey[128] = K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11, K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 }; @@ -942,7 +942,7 @@ byte shiftscantokey[128] = K_UPARROW,K_PGUP,'_',K_LEFTARROW,'%',K_RIGHTARROW,'+',K_END, //4 K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11, K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5 - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 @@ -984,7 +984,7 @@ ClearAllStates void ClearAllStates (void) { int i; - + // send an up event for each key, to make sure the server clears them all for (i=0 ; i<256 ; i++) { @@ -1284,7 +1284,7 @@ char *VID_GetExtModeDescription (int mode) if (modestate == MS_WINDOWED) snprintf (pinfo, sizeof(pinfo), "%s windowed", pv->modedesc); else - strcpy (pinfo, "windowed"); + snprintf (pinfo, sizeof(pinfo), "windowed"); } return pinfo; @@ -1403,7 +1403,7 @@ void VID_InitDIB (HINSTANCE hInstance) if (modelist[0].height < 240) modelist[0].height = 240; - sprintf (modelist[0].modedesc, "%dx%d", + snprintf (modelist[0].modedesc, sizeof(modelist[0].modedesc), "%dx%d", modelist[0].width, modelist[0].height); modelist[0].modenum = MODE_WINDOWED; @@ -1456,7 +1456,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel); @@ -1468,7 +1468,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) { modelist[nummodes].width >>= 1; modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%dx%d", modelist[nummodes].width, modelist[nummodes].height, modelist[nummodes].bpp); @@ -1521,7 +1521,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel); @@ -1761,7 +1761,7 @@ void VID_Init (unsigned char *palette) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = bpp; - sprintf (modelist[nummodes].modedesc, "%dx%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);