From d07fa0b656e012300cba62fccd867e5cb93e3460 Mon Sep 17 00:00:00 2001 From: "damian.ionic" <damian@ionic.io> Date: Thu, 11 Jan 2024 07:58:59 -0800 Subject: [PATCH] fix: paths contain non-ascii characters cause error --- src/ios/lib/client/afc.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ios/lib/client/afc.ts b/src/ios/lib/client/afc.ts index 02aa1c0..360c37f 100644 --- a/src/ios/lib/client/afc.ts +++ b/src/ios/lib/client/afc.ts @@ -52,7 +52,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> { async openFile(path: string): Promise<Buffer> { debug(`openFile: ${path}`); // mode + path + null terminator - const data = Buffer.alloc(8 + path.length + 1); + const data = Buffer.alloc(8 + Buffer.byteLength(path) + 1); // write mode data.writeUInt32LE(AFC_FILE_OPEN_FLAGS.WRONLY, 0); // then path to file @@ -176,7 +176,7 @@ export class AFCClient extends ServiceClient<AFCProtocolClient> { } function toCString(s: string) { - const buf = Buffer.alloc(s.length + 1); + const buf = Buffer.alloc(Buffer.byteLength(s) + 1); const len = buf.write(s); buf.writeUInt8(0, len); return buf;