shithub: vexed

Download patch

ref: cb5acb9aa60af386de6910318307ed5927c5dc3f
parent: 59f58defd6196ae6aed046c34d97f72bcb0ecba0
author: phil9 <telephil9@gmail.com>
date: Mon Feb 19 04:34:38 EST 2024

fix decode shifting from the wrong side

--- a/dec.c
+++ b/dec.c
@@ -28,7 +28,7 @@
 
 	r = 0;
 	for(i = 0; i < 2; i++)
-		r += (u16int)(b[6 + i] << 8*i);
+		r += (u16int)(b[6 + i] << 8*(2-i-1));
 	return r;
 }
 
@@ -40,7 +40,7 @@
 
 	r = 0;
 	for(i = 0; i < 2; i++)
-		r += (s16int)(b[6 + i] << 8*i);
+		r += (s16int)(b[6 + i] << 8*(2-i-1));
 	return r;
 }
 
@@ -52,7 +52,7 @@
 
 	r = 0;
 	for(i = 0; i < 4; i++)
-		r += (u32int)(b[4 + i] << 8*i);
+		r += (u32int)(b[4 + i] << 8*(4-i-1));
 	return r;
 }
 
@@ -64,7 +64,7 @@
 
 	r = 0;
 	for(i = 0; i < 4; i++)
-		r += (s32int)(b[4 + i] << 8*i);
+		r += (s32int)(b[4 + i] << 8*(4-i-1));
 	return r;
 }
 
@@ -76,7 +76,7 @@
 
 	r = 0;
 	for(i = 0; i < 8; i++)
-		r += (u64int)(b[i] << 8*i); 
+		r += (u64int)(b[i] << 8*(8-i-1)); 
 	return r;
 }
 
@@ -88,7 +88,7 @@
 
 	r = 0;
 	for(i = 0; i < 8; i++)
-		r += (s64int)(b[i] << 8*i);
+		r += (s64int)(b[i] << 8*(8-i-1));
 	return r;
 }