mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Fix pixel change record bounds check
From cursor review: Insufficient bounds checking for pixel change records (type 2) in renderTileToPixels, extractAvailableTicks, and parseTileData. The code checks for 6 bytes of header data but reads 10 bytes (tick, pixelCount, newColor, oldColor), potentially leading to reading out of bounds. The check should be offset + 10 > tileData.length.
This commit is contained in:
1 parent
2bce506d96
commit
14f69cda11
2 files changed
+5
-4
No files matched your search
@@ -243,7 +243,7 @@ function processPixelData(
|
||||
currentPixels: Uint16Array,
|
||||
maxTick?: number
|
||||
): { success: boolean; newOffset: number } {
|
||||
if (offset + 6 > tileData.length) {
|
||||
if (offset + 10 > tileData.length) {
|
||||
return { success: false, newOffset: offset };
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ export function extractAvailableTicks(tileData: BinaryData): number[] {
|
||||
offset += 2;
|
||||
offset += length; // Skip chunk data
|
||||
} else if (type === 2) { // Pixels
|
||||
if (offset + 6 > tileData.length) {
|
||||
if (offset + 10 > tileData.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ function parsePixelChangeRecord(
|
||||
pixelChanges: PixelChangeRecord[],
|
||||
ticks: Set<number>
|
||||
): { success: boolean; newOffset: number } {
|
||||
if (offset + 6 > tileData.length) {
|
||||
if (offset + 10 > tileData.length) {
|
||||
return { success: false, newOffset: offset };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user