Skip to contentSkip to conversation

Prevent zero sized wl_egl_window

PATCH In review Sinclair Yeh 4 participants 5 messages Feb 13, 2014 – Feb 18, 2014 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prevent zero sized wl_egl_window

It is illegal to create or resize a window to zero (or negative) width and/or height. This patch prevents such a request from happening.

---
 src/egl/wayland/wayland-egl/wayland-egl.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/egl/wayland/wayland-egl/wayland-egl.c +6 -0
index 8bd49cf..ae78595 100644
@@ -9,6 +9,9 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
 		     int width, int height,
 		     int dx, int dy)
 {
+	if (width <= 0 || height <= 0)
+		return;
+
 	egl_window->width  = width;
 	egl_window->height = height;
 	egl_window->dx     = dx;
@@ -24,6 +27,9 @@ wl_egl_window_create(struct wl_surface *surface,
 {
 	struct wl_egl_window *egl_window;
 
+	if (width <= 0 || height <= 0)
+		return NULL;
+
 	egl_window = malloc(sizeof *egl_window);
 	if (!egl_window)
 		return NULL;
Signature · 1 line
1.8.1.4

A message that is not in the archive (sent off-list or not yet received): 1392250871-3224-1-git-send-email-sinclair.yeh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 11 lines · On Wed, 12 Feb 2014 16:21:11 -0800 Sinclair Yeh…

It is illegal to create or resize a window to zero (or negative) width and/or height. This patch prevents such a request from happening.

---
 src/egl/wayland/wayland-egl/wayland-egl.c | 6 ++++++
 1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/src/egl/wayland/wayland-egl/wayland-egl.c index 8bd49cf..ae78595 100644 --- a/src/egl/wayland/wayland-egl/wayland-egl.c +++ b/src/egl/wayland/wayland-egl/wayland-egl.c

src/egl/wayland/wayland-egl/wayland-egl.c wl_egl_window_resize(struct wl_egl_window *egl_window, · line 14

Quoted 6 lines
src/egl/wayland/wayland-egl/wayland-egl.c +3 -0
@@ -9,6 +9,9 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
 		     int width, int height,
 		     int dx, int dy)
 {
+	if (width <= 0 || height <= 0)
+		return;
+

The below seems fine, but I wonder if we could make this one cause an error to be returned later where we can, rather than silently ignoring. I'm not sure where or how, though.

Surely drivers have maximum size limits, too, those must be catched somewhere already.

src/egl/wayland/wayland-egl/wayland-egl.c wl_egl_window_create(struct wl_surface *surface, · line 35

Quoted 13 lines
src/egl/wayland/wayland-egl/wayland-egl.c +3 -0
 	egl_window->width  = width;
 	egl_window->height = height;
 	egl_window->dx     = dx;
@@ -24,6 +27,9 @@ wl_egl_window_create(struct wl_surface *surface,
 {
 	struct wl_egl_window *egl_window;
 
+	if (width <= 0 || height <= 0)
+		return NULL;
+
 	egl_window = malloc(sizeof *egl_window);
 	if (!egl_window)
 		return NULL;

Thanks,
pq

#3 lore raw
Quoted 3 lines

The below seems fine, but I wonder if we could make this one cause an error to be returned later where we can, rather than silently ignoring. I'm not sure where or how, though.

Would it make sense to change wl_egl_window_resize() so that it return a value? Either that, or it should be documented somewhere in the API spec that setting width/height <=0 will be ignored.

Quoted 24 lines

Surely drivers have maximum size limits, too, those must be catched somewhere already.

src/egl/wayland/wayland-egl/wayland-egl.c wl_egl_window_create(struct wl_surface *surface, · line 35

Quoted 13 lines
src/egl/wayland/wayland-egl/wayland-egl.c +3 -0
 	egl_window->width  = width;
 	egl_window->height = height;
 	egl_window->dx     = dx;
@@ -24,6 +27,9 @@ wl_egl_window_create(struct wl_surface *surface,
 {
 	struct wl_egl_window *egl_window;
 
+	if (width <= 0 || height <= 0)
+		return NULL;
+
 	egl_window = malloc(sizeof *egl_window);
 	if (!egl_window)
 		return NULL;

Thanks,
pq
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

A message that is not in the archive (sent off-list or not yet received): 1392315418.3247.29.camel-xjpeL9Jkt2k8a1ujtQqgMq2pdiUAq4bhAL8bYrjMMd8@public.gmane.org

#5 lore raw
Quoted 7 lines · Sinclair
Quoted 3 lines

The below seems fine, but I wonder if we could make this one cause an error to be returned later where we can, rather than silently ignoring. I'm not sure where or how, though.

Would it make sense to change wl_egl_window_resize() so that it return a value? Either that, or it should be documented somewhere in the API spec that setting width/height <=0 will be ignored.

I'm not sure we can change the function signature, it's public stable ABI.

Quoted 2 lines
Quoted 2 lines

Surely drivers have maximum size limits, too, those must be catched somewhere already.

But this might be worth looking into: if the window system produces a bad size, what do drivers do when they cannot allocate or render to it?

In X11 it's all hidden from the app, but I don't think the gfx stack can guarantee valid sizes in all cases, can it?

Anyway, my suggestion is just for convenience, and if drivers already just silently do whatever on a bad size, being silent here does not make it any worse.

Thanks,
pq

Quoted 22 lines
Quoted 21 lines
Quoted 5 lines
src/egl/wayland/wayland-egl/wayland-egl.c +0 -0
 	egl_window->width  = width;
 	egl_window->height = height;
 	egl_window->dx     = dx;

src/egl/wayland/wayland-egl/wayland-egl.c wl_egl_window_create(struct wl_surface *surface, · line 35

Quoted 9 lines
src/egl/wayland/wayland-egl/wayland-egl.c +3 -0
@@ -24,6 +27,9 @@ wl_egl_window_create(struct wl_surface *surface,
 {
 	struct wl_egl_window *egl_window;
 
+	if (width <= 0 || height <= 0)
+		return NULL;
+
 	egl_window = malloc(sizeof *egl_window);
 	if (!egl_window)
 		return NULL;

Thanks,
pq
_______________________________________________
wayland-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 20 lines · Pekka Paalanen
Quoted 7 lines · Sinclair
Quoted 3 lines

The below seems fine, but I wonder if we could make this one cause an error to be returned later where we can, rather than silently ignoring. I'm not sure where or how, though.

Would it make sense to change wl_egl_window_resize() so that it return a value? Either that, or it should be documented somewhere in the API spec that setting width/height <=0 will be ignored.

I'm not sure we can change the function signature, it's public stable ABI.

Quoted 2 lines
Quoted 2 lines

Surely drivers have maximum size limits, too, those must be catched somewhere already.

But this might be worth looking into: if the window system produces a bad size, what do drivers do when they cannot allocate or render to it?

Quoted 6 lines

In X11 it's all hidden from the app, but I don't think the gfx stack can guarantee valid sizes in all cases, can it?

Anyway, my suggestion is just for convenience, and if drivers already just silently do whatever on a bad size, being silent here does not make it any worse.

We could maybe make it raise an EGL error, I'm a little concerned with how this silently fails. However, the behavior with Sinclairs patch is better than what we had before, so I've pushed that.

Quoted 30 lines

Thanks,
pq

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +0 -0
 	egl_window->width  = width;
 	egl_window->height = height;
 	egl_window->dx     = dx;
@@ -24,6 +27,9 @@ wl_egl_window_create(struct wl_surface *surface,
 {
 	struct wl_egl_window *egl_window;
 
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +3 -0
+	if (width <= 0 || height <= 0)
+		return NULL;
+
 	egl_window = malloc(sizeof *egl_window);
 	if (!egl_window)
Quoted 8 lines

Review wl_egl_window_create(struct wl_surface *surface, · line 35

Quoted 1 line
(quoted diff) +0 -0
 		return NULL;

Thanks,
pq
_______________________________________________
wayland-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

_______________________________________________
wayland-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel