Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Nov 2012 23:24:24 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 219786 for review
Message-ID:  <201211142324.qAENOOA8025600@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211142324.qAENOOA8025600>