From owner-p4-projects@FreeBSD.ORG Wed Nov 14 23:24:25 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5CB9C241; Wed, 14 Nov 2012 23:24:25 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1167B23D for ; Wed, 14 Nov 2012 23:24:25 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id D0D688FC08 for ; Wed, 14 Nov 2012 23:24:24 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qAENOOVW025603 for ; Wed, 14 Nov 2012 23:24:24 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qAENOOA8025600 for perforce@freebsd.org; Wed, 14 Nov 2012 23:24:24 GMT (envelope-from brooks@freebsd.org) Date: Wed, 14 Nov 2012 23:24:24 GMT Message-Id: <201211142324.qAENOOA8025600@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219786 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Nov 2012 23:24:25 -0000 http://p4web.freebsd.org/@@219786?ac=10 Change 219786 by brooks@brooks_zenith on 2012/11/14 23:24:03 Fix two bugs the prevented CHERI sandboxes from working. - Initialize all the important fields of of struct iboxstate - The row callback was overflowing our output capability. Don't use the callback and just write the buffer out in one go at the end since we only support run to completion from the start routine. A few cleanups and warning switches. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/readpng-cheri.c#3 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/libexec/readpng-cheri/readpng-cheri.c#3 (text+ko) ==== @@ -47,8 +47,8 @@ int pngwidth; int offset = 0; -void -cheri_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +static void +cheri_read_data(png_structp png_ptr __unused, png_bytep data, png_size_t length) { memcpy_fromcap(data, 2, offset, length); @@ -56,14 +56,18 @@ } static void -cheri_read_row_callback(png_structp png_ptr, png_uint_32 row, int pass __unused) +cheri_read_row_callback(png_structp png_ptr __unused, png_uint_32 row __unused, + int pass __unused) { +#if 0 struct ibox_decode_state *ids; ids = png_get_io_ptr(png_ptr); - memcpy_tocap(1, ids->buffer + (pngwidth * row), - sizeof(uint32_t) * pngwidth * row, sizeof(uint32_t) * pngwidth); + memcpy_tocap(1, ids->buffer + (pngwidth * (row - 1)), + sizeof(uint32_t) * pngwidth * (row - 1), + sizeof(uint32_t) * pngwidth); +#endif } /* @@ -71,19 +75,21 @@ * * The output buffer is passed in c1. The pngfile is accessable via c2. * a0 holds the image width, a1 the height, and a2 holds the length of the - * pngfile. a3 holds the slide number. + * pngfile (currently unused). a3 holds the slide number. */ int -invoke(register_t a0, register_t a1, register_t a2, +invoke(register_t a0, register_t a1, register_t a2 __unused, register_t a3) { struct ibox_decode_state ids; struct iboxstate is; - u_int i; - uint32_t white = 0xFFFFFFFF; pngwidth = a0; + is.width = a0; + is.height = a1; + is.error = 0; + ids.fd = -1; ids.slide = a3; /* @@ -96,5 +102,9 @@ decode_png(&ids, cheri_read_data, cheri_read_row_callback); - return (123456); + /* Copy the whole image out */ + if (is.error == 0) + memcpy_tocap(1, ids.buffer, 0, sizeof(uint32_t) * a0 * a1); + + return (is.error); }