progs/xdemos: Check for string overflow.
authorVinson Lee <vlee@vmware.com>
Thu, 7 Jan 2010 02:08:17 +0000 (18:08 -0800)
committerVinson Lee <vlee@vmware.com>
Thu, 7 Jan 2010 02:08:41 +0000 (18:08 -0800)
progs/xdemos/sharedtex_mt.c

index f924448cc436444b520bf3f52297b314f53a69d3..a90903adeca7e098ffa8daf510d78aa97f766d2d 100644 (file)
@@ -174,6 +174,10 @@ AddWindow(Display *dpy, const char *displayName, int xpos, int ypos,
    {
       static int id = 0;
       struct window *h = &Windows[NumWindows];
+      if (strlen(displayName) + 1 > sizeof(h->DisplayName)) {
+         Error(displayName, "string overflow");
+         return NULL;
+      }
       strcpy(h->DisplayName, displayName);
       h->Dpy = dpy;
       h->Win = win;