summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2011-06-06 18:22:59 -0400
committerEamon Walsh <ewalsh@tycho.nsa.gov>2011-06-06 18:34:22 -0400
commit755301b1326cdc22d9e485d151f52f2993054762 (patch)
tree3fac8d9d47d61b471db53087b90c9e6254e5306d /src
parent3faee5d417bb0f162405a6e0ca1c6ab25e9a6b19 (diff)
Forbid clients from creating or referencing views with reserved ID 0.
Diffstat (limited to 'src')
-rw-r--r--src/comm.c2
-rw-r--r--src/view.c9
-rw-r--r--src/view.h1
3 files changed, 8 insertions, 4 deletions
diff --git a/src/comm.c b/src/comm.c
index 2ae22d2..06ca63b 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -90,7 +90,7 @@ comm_create(struct client *c, struct buffer *b, struct lin_message *m)
if (v)
FD_LOG(1, "Warning: view %x already exists.\n", m->view);
else {
- v = view_new(c, b, m->view, 0);
+ v = view_new(c, b, m->view, VIEW_FLAGS_CLIENT);
if (!v) {
FD_LOG(0, "Failed to create view!\n");
return;
diff --git a/src/view.c b/src/view.c
index 029bf33..20b7475 100644
--- a/src/view.c
+++ b/src/view.c
@@ -75,9 +75,10 @@ view_lookup(struct client *c, int viewid)
{
struct view *v;
- TAILQ_FOREACH(v, &c->views, client_next)
- if (v->id == viewid)
- return v;
+ if (viewid != 0)
+ TAILQ_FOREACH(v, &c->views, client_next)
+ if (v->id == viewid)
+ return v;
return NULL;
@@ -184,6 +185,8 @@ view_new(struct client *c, struct buffer *b, int id, unsigned int flags)
if (c->num_views >= c->max_views)
return NULL;
+ if (flags == VIEW_FLAGS_CLIENT && id == 0)
+ return NULL;
/* create subsurface */
if (b->bsurface->GetSubSurface(b->bsurface, NULL, &vsurf) != DFB_OK)
diff --git a/src/view.h b/src/view.h
index a8f10e1..af68215 100644
--- a/src/view.h
+++ b/src/view.h
@@ -36,6 +36,7 @@
#include "sys-queue.h"
+#define VIEW_FLAGS_CLIENT 0x1 /* view was created by a client */
#define VIEW_FLAGS_BACKGROUND 0x2 /* view is a background view */
#define VIEW_FLAGS_THUMBNAIL 0x4 /* view is a thumbnail view */