From ea4e690b8e8eeefa648cae0ad46a1c4905ac66e7 Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Tue, 6 May 2025 15:31:45 +0900 Subject: [PATCH] fix: lua script stops output if it includes null terminate --- src/script.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/script.c b/src/script.c index b471932..1e46a33 100644 --- a/src/script.c +++ b/src/script.c @@ -187,7 +187,9 @@ static int modem_send(lua_State *L) // lua: send(string) static int write_(lua_State *L) { - const char *string = lua_tostring(L, 1); + size_t len = 0; + const char *string = lua_tolstring(L, 1, &len); + int ret; if (string == NULL) @@ -195,7 +197,7 @@ static int write_(lua_State *L) return 0; } - ret = write(device_fd, string, strlen(string)); + ret = write(device_fd, string, len); fsync(device_fd); // flush these characters now tcdrain(device_fd); //ensure we flushed characters to our device