Bimba.git

commit c0d2b3b799f419698bcb28de7f593d86ecbe682c

Author: Adam <git@apiote.xyz>

fruchtfleisch: fix unmarshalling strings

 fruchtfleisch/src/main/java/xyz/apiote/fruchtfleisch/Reader.kt | 8 +++-


diff --git a/fruchtfleisch/src/main/java/xyz/apiote/fruchtfleisch/Reader.kt b/fruchtfleisch/src/main/java/xyz/apiote/fruchtfleisch/Reader.kt
index 9d49df734169f7b2934d7897e89311653de7139c..1f22ccb5807e8f6cf8c60ad24e3dfa1a42aaef88 100644
--- a/fruchtfleisch/src/main/java/xyz/apiote/fruchtfleisch/Reader.kt
+++ b/fruchtfleisch/src/main/java/xyz/apiote/fruchtfleisch/Reader.kt
@@ -30,6 +30,7 @@ 				}
 				result = result.or(b.toULong().shl(s))
 				break
 			}
+			result = result.or(b.toULong().and(127u).shl(s))
 			i++
 			s += 7
 		}
@@ -108,14 +109,17 @@ 		val data = ByteArray(n)
 		var left = n
 		while (left > 0) {
 			val r = stream.read(data, n - left, left)
+			if (r == -1) {
+				break
+			}
 			left -= r
 		}
 		return data
 	}
 
 	fun readString(): String {
-		val length = readU8()
-		return readData(length.toInt()).decodeToString()
+		val length = readUInt()
+		return readData(length.toULong().toInt()).decodeToString()
 	}
 
 	fun readBoolean(): Boolean {