mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Fix pixel parsing offset error
This commit is contained in:
1 parent
14f69cda11
commit
57f89de746
1 file changed
+3
-3
@@ -420,7 +420,7 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
existingTile: Buffer,
|
existingTile: Buffer,
|
||||||
offset: number
|
offset: number
|
||||||
): { success: boolean, newOffset: number } {
|
): { success: boolean, newOffset: number } {
|
||||||
if (offset + 6 > existingTile.length) {
|
if (offset + 10 > existingTile.length) {
|
||||||
this.logger.error(`Invalid tile data: insufficient pixel header data at offset ${offset}`);
|
this.logger.error(`Invalid tile data: insufficient pixel header data at offset ${offset}`);
|
||||||
return { success: false, newOffset: offset };
|
return { success: false, newOffset: offset };
|
||||||
}
|
}
|
||||||
@@ -428,8 +428,8 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
const tick = existingTile.readUInt32BE(offset);
|
const tick = existingTile.readUInt32BE(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
const pixelCount = existingTile.readUInt16BE(offset);
|
const pixelCount = existingTile.readUInt16BE(offset);
|
||||||
offset += 2;
|
offset += 2 + 2 + 2; // Skip newColor and oldColor
|
||||||
const pixelDataLength = pixelCount * 6;
|
const pixelDataLength = pixelCount * 2;
|
||||||
|
|
||||||
if (offset + pixelDataLength > existingTile.length) {
|
if (offset + pixelDataLength > existingTile.length) {
|
||||||
this.logger.error(`Invalid tile data: insufficient pixel data at offset ${offset}`);
|
this.logger.error(`Invalid tile data: insufficient pixel data at offset ${offset}`);
|
||||||
|
|||||||
Reference in new issue
Block a user