Fix reading timestamps with sign bit set

lo should've been masked rather than hi. I've switched the code to mask
both the low and high DWORDs for simplicity.

Signed-off-by: Graham <gpe@openrs2.org>
Graham 3 years ago
parent ddecca5d0b
commit 88ef8aec92
  1. 4
      archive/src/main/kotlin/org/openrs2/archive/cache/finder/CacheFinderExtractor.kt

@ -22,7 +22,7 @@ public class CacheFinderExtractor(
private val input = LittleEndianDataInputStream(pushbackInput) private val input = LittleEndianDataInputStream(pushbackInput)
private fun readTimestamp(): FileTime { private fun readTimestamp(): FileTime {
val lo = input.readInt().toLong() val lo = input.readInt().toLong() and 0xFFFFFFFF
val hi = input.readInt().toLong() and 0xFFFFFFFF val hi = input.readInt().toLong() and 0xFFFFFFFF
val seconds = (((hi shl 32) or lo) / 10_000_000) - FILETIME_TO_UNIX_EPOCH val seconds = (((hi shl 32) or lo) / 10_000_000) - FILETIME_TO_UNIX_EPOCH
@ -102,7 +102,7 @@ public class CacheFinderExtractor(
val atime = readTimestamp() val atime = readTimestamp()
val mtime = readTimestamp() val mtime = readTimestamp()
val sizeHi = input.readInt().toLong() val sizeHi = input.readInt().toLong() and 0xFFFFFFFF
val sizeLo = input.readInt().toLong() and 0xFFFFFFFF val sizeLo = input.readInt().toLong() and 0xFFFFFFFF
val size = (sizeHi shl 32) or sizeLo val size = (sizeHi shl 32) or sizeLo

Loading…
Cancel
Save