Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Writing file with file size >2GB #5

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions websocket-sftp/lib/sftp-packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,17 @@ export class SftpPacketReader extends SftpPacket {
}

readInt64(): number {
const hi = this.readInt32();
const lo = this.readUInt32();

const value = hi * 0x100000000 + lo;
return value;
this.check(8);
const value = this.buffer.readBigInt64BE(this.position);
this.position += 8;
return Number(value);
}

readUInt64(): number {
const hi = this.readUInt32();
const lo = this.readUInt32();
const value = hi * 0x100000000 + lo;
return value;
this.check(8);
const value = this.buffer.readBigUint64BE(this.position);
this.position += 8;
return Number(value);
}

readString(): string {
Expand Down Expand Up @@ -271,17 +270,15 @@ export class SftpPacketWriter extends SftpPacket {
}

writeInt64(value: number): void {
const hi = (value / 0x100000000) | 0;
const lo = (value & 0xffffffff) | 0;
this.writeInt32(hi);
this.writeInt32(lo);
this.check(8);
this.buffer.writeBigInt64BE(BigInt(value), this.position);
this.position += 8;
}

writeUInt64(value: number): void {
const hi = (value / 0x100000000) | 0;
const lo = (value & 0xffffffff) | 0;
this.writeUInt32(hi);
this.writeUInt32(lo);
this.check(8);
this.buffer.writeBigUInt64BE(BigInt(value), this.position);
this.position += 8;
}

writeString(value: string): void {
Expand Down
Loading