Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 4b6e46f

Browse files
authored
cleanup magic (#18)
* cleanup magic * updated devicescript
1 parent b5ec2b5 commit 4b6e46f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/interop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export {
1212
SideUploadJsonFromDevice,
1313
SideExceptionFromDevice,
1414
} from "../devicescript/interop/src/interop"
15-
15+
export * from "../devicescript/compiler/src/magic"
1616
export { parseStackFrame } from "../devicescript/interop/src/debug"

src/wssk.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
WsskDataType,
3131
WsskStreamingType,
3232
parseStackFrame,
33+
IMAGE_MIN_LENGTH,
34+
checkMagic
3335
} from "./interop"
3436
import { ingestLogs, ingestMessage } from "./messages"
3537
import {
@@ -380,11 +382,10 @@ export class ConnectedDevice {
380382
try {
381383
const body = await getScriptBody(d.scriptId, d.scriptVersion)
382384
const tmp = Buffer.from(body.program.binary.hex, "hex")
383-
if (tmp.length < 128) this.warn(`compiled program too short`)
385+
if (tmp.length < IMAGE_MIN_LENGTH) this.warn(`compiled program too short`)
384386
else {
385-
const hd = tmp.slice(0, 8).toString("hex")
386-
if (hd != "446576530a7e6a9a") {
387-
this.warn(`compiled program bad magic ${hd}`)
387+
if (!checkMagic(tmp)) {
388+
this.warn(`compiled program bad magic ${tmp.slice(0, 8).toString("hex")}`)
388389
} else this.setDeploy(tmp)
389390
}
390391
} catch (e: any) {

0 commit comments

Comments
 (0)