shithub: sce

Download patch

ref: a806c098ae69c06691066449ae09fb129b19576a
parent: 41a004af782c71c7f72e06c727e10a2ef9c26c01
author: qwx <qwx@sciops.net>
date: Fri Feb 25 02:51:56 EST 2022

bmap: fix oob from assumed max unit size

detected because it messed up execution depending on the order of
linked objects, crazy

--- a/bmap.c
+++ b/bmap.c
@@ -5,7 +5,7 @@
 #include "fns.h"
 
 enum{
-	Nmaxsize = 4,
+	Nmaxsize = 4*4,	/* FIXME: seems like a shitty assumption to make */
 	Npad = 1,
 };
 
@@ -93,6 +93,7 @@
 	int i, j;
 	u64int u, m;
 
+	memset(row, 0xfe, sizeof row);
 	m = (1 << sz.x - 1) - 1;
 	if(left){
 		ofs = 64 - sz.x - Δsz.x - ofs;
@@ -100,6 +101,7 @@
 	}
 	m = ~m;
 	for(i=0; i<sz.y+Δsz.y; i++, b+=Δb){
+		assert(i < nelem(row));
 		u = b[0];
 		if(ofs > 0){
 			if(left){