Chris Robinson : wined3d: Use a safer,
more compliant method to parse extension strings.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Aug 10 07:31:11 CDT 2007
Module: wine
Branch: master
Commit: c8b6b2b1d83c2c44940562f02a1f6690637b4142
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c8b6b2b1d83c2c44940562f02a1f6690637b4142
Author: Chris Robinson <chris.kcat at gmail.com>
Date: Wed Aug 8 09:57:39 2007 -0700
wined3d: Use a safer, more compliant method to parse extension strings.
---
dlls/wined3d/directx.c | 38 +++++++++++++++++++++++++-------------
1 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e8613c3..75951ea 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -627,14 +627,22 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
ERR(" GL_Extensions returns NULL\n");
} else {
while (*GL_Extensions != 0x00) {
- const char *Start = GL_Extensions;
+ const char *Start;
char ThisExtn[256];
+ size_t len;
- memset(ThisExtn, 0x00, sizeof(ThisExtn));
- while (*GL_Extensions != ' ' && *GL_Extensions != 0x00) {
+ while (isspace(*GL_Extensions)) GL_Extensions++;
+ Start = GL_Extensions;
+ while (!isspace(*GL_Extensions) && *GL_Extensions != 0x00) {
GL_Extensions++;
}
- memcpy(ThisExtn, Start, (GL_Extensions - Start));
+
+ len = GL_Extensions - Start;
+ if (len == 0 || len >= sizeof(ThisExtn))
+ continue;
+
+ memcpy(ThisExtn, Start, len);
+ ThisExtn[len] = '\0';
TRACE_(d3d_caps)("- %s\n", ThisExtn);
for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i) {
@@ -644,8 +652,6 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
break;
}
}
-
- if (*GL_Extensions == ' ') GL_Extensions++;
}
if (gl_info->supported[APPLE_FENCE]) {
@@ -998,22 +1004,28 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
ERR(" WGL_Extensions returns NULL\n");
} else {
while (*WGL_Extensions != 0x00) {
- const char *Start = WGL_Extensions;
+ const char *Start;
char ThisExtn[256];
+ size_t len;
- memset(ThisExtn, 0x00, sizeof(ThisExtn));
- while (*WGL_Extensions != ' ' && *WGL_Extensions != 0x00) {
+ while (isspace(*WGL_Extensions)) WGL_Extensions++;
+ Start = WGL_Extensions;
+ while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) {
WGL_Extensions++;
}
- memcpy(ThisExtn, Start, (WGL_Extensions - Start));
+
+ len = WGL_Extensions - Start;
+ if (len == 0 || len >= sizeof(ThisExtn))
+ continue;
+
+ memcpy(ThisExtn, Start, len);
+ ThisExtn[len] = '\0';
TRACE_(d3d_caps)("- %s\n", ThisExtn);
- if (strstr(ThisExtn, "WGL_ARB_pbuffer")) {
+ if (!strcmp(ThisExtn, "WGL_ARB_pbuffer")) {
gl_info->supported[WGL_ARB_PBUFFER] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_ARB_pbuffer support\n");
}
-
- if (*WGL_Extensions == ' ') WGL_Extensions++;
}
}
}
More information about the wine-cvs
mailing list