From b1e04dbac4d2504f2a91359c1cd1310afcf60bc6 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sun, 28 Apr 2013 18:07:05 +1000 Subject: [PATCH] avoid overflowing buffer with GL_EXTENSIONS, from ioquake3 --- CODE-mp/renderer/tr_init.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CODE-mp/renderer/tr_init.cpp b/CODE-mp/renderer/tr_init.cpp index c9d0403..294bd52 100644 --- a/CODE-mp/renderer/tr_init.cpp +++ b/CODE-mp/renderer/tr_init.cpp @@ -707,6 +707,27 @@ void GL_SetDefaultState( void ) qglDisable( GL_BLEND ); } +/* +================ +R_PrintLongString + +Workaround for ri.Printf's 4096 characters buffer limit. +================ +*/ +void R_PrintLongString(const char *string) { + char buffer[4096]; + const char *p; + int size = strlen(string); + + p = string; + while(size > 0) + { + Q_strncpyz(buffer, p, sizeof (buffer) ); + ri.Printf( PRINT_ALL, "%s", buffer ); + p += 4095; + size -= 4095; + } +} /* ================ @@ -737,7 +758,9 @@ void GfxInfo_f( void ) ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); - ri.Printf( PRINT_ALL, "GL_EXTENSIONS: %s\n", glConfig.extensions_string ); + ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " ); + R_PrintLongString( glConfig.extensions_string ); + ri.Printf( PRINT_ALL, "\n" ); ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); ri.Printf( PRINT_ALL, "GL_MAX_ACTIVE_TEXTURES_ARB: %d\n", glConfig.maxActiveTextures ); ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );