summaryrefslogtreecommitdiff
path: root/progs/xdemos/glxheads.c
diff options
context:
space:
mode:
Diffstat (limited to 'progs/xdemos/glxheads.c')
-rw-r--r--progs/xdemos/glxheads.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/progs/xdemos/glxheads.c b/progs/xdemos/glxheads.c
index b1a63d3d50..edae0a3ef7 100644
--- a/progs/xdemos/glxheads.c
+++ b/progs/xdemos/glxheads.c
@@ -145,14 +145,40 @@ AddHead(const char *displayName)
/* save the info for this head */
{
struct head *h = &Heads[NumHeads];
+ const char * tmp;
+
+ if (strlen(displayName) + 1 > sizeof(h->DisplayName)) {
+ Error(displayName, "displayName string length overflow");
+ return NULL;
+ }
strcpy(h->DisplayName, displayName);
+
h->Dpy = dpy;
h->Win = win;
h->Context = ctx;
h->Angle = 0.0;
- strcpy(h->Version, (char *) glGetString(GL_VERSION));
- strcpy(h->Vendor, (char *) glGetString(GL_VENDOR));
- strcpy(h->Renderer, (char *) glGetString(GL_RENDERER));
+
+ tmp = (char *) glGetString(GL_VERSION);
+ if (strlen(tmp) + 1 > sizeof(h->Version)) {
+ Error(displayName, "GL_VERSION string length overflow");
+ return NULL;
+ }
+ strcpy(h->Version, tmp);
+
+ tmp = (char *) glGetString(GL_VENDOR);
+ if (strlen(tmp) + 1 > sizeof(h->Vendor)) {
+ Error(displayName, "GL_VENDOR string length overflow");
+ return NULL;
+ }
+ strcpy(h->Vendor, tmp);
+
+ tmp = (char *) glGetString(GL_RENDERER);
+ if (strlen(tmp) + 1 > sizeof(h->Renderer)) {
+ Error(displayName, "GL_RENDERER string length overflow");
+ return NULL;
+ }
+ strcpy(h->Renderer, tmp);
+
NumHeads++;
return &Heads[NumHeads-1];
}