PERFORCE change 219786 for review

Brooks Davis brooks at FreeBSD.org
Wed Nov 14 23:24:25 UTC 2012


http://p4web.freebsd.org/@@219786?ac=10

Change 219786 by brooks at 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);
 }


More information about the p4-projects mailing list