mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 20:40:09 +01:00
progs/xdemos: Check for string overflow.
This commit is contained in:
parent
25ffd76278
commit
45ac10fe6a
1 changed files with 29 additions and 3 deletions
|
|
@ -177,14 +177,40 @@ AddHead(const char *displayName, const char *name)
|
|||
/* save the info for this head */
|
||||
{
|
||||
struct head *h = &Heads[NumHeads];
|
||||
const char * tmp;
|
||||
|
||||
if (strlen(name) + 1 > sizeof(h->DisplayName)) {
|
||||
Error(displayName, "name string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->DisplayName, name);
|
||||
|
||||
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 overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Version, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_VENDOR);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Vendor)) {
|
||||
Error(displayName, "GL_VENDOR string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Vendor, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_RENDERER);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Renderer)) {
|
||||
Error(displayName, "GL_RENDERER string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Renderer, tmp);
|
||||
|
||||
NumHeads++;
|
||||
return &Heads[NumHeads-1];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue