depth);
return -1;
}
- if (row_stride < 0 || row_stride > fb_len) {
+ if (row_stride <= 0 || row_stride > fb_len) {
fprintf(stderr,
"FB: invalid frontend stride %d\n", row_stride);
return -1;
vnc_write_s32(vs, encoding);
}
+static int mult_overflows(int x, int y)
+{
+ if (x<=0 || y<=0 || x>=INT_MAX/y)
+ return 1;
+ else return 0;
+}
+
static void vnc_dpy_resize_shared(DisplayState *ds, int w, int h, int depth, int linesize, void *pixels)
{
static int allocated;
int o;
vnc_colourdepth(ds, depth);
+ if (mult_overflows(w, h) || mult_overflows(w*h, vs->depth) ||
+ mult_overflows(h, sizeof(vs->dirty_row[0]))) {
+ fprintf(stderr, "vnc: suspicious vnc_dpy_resize arguments"
+ " (w=%d h=%d depth=%d linesize=%d vs->depth=%d), exiting\n",
+ w, h, depth, linesize, vs->depth);
+ exit(1);
+ }
if (!ds->shared_buf) {
ds->linesize = w * vs->depth;
if (allocated)