fix(launcher): App暴毙后卡死根因——execpipe 裸阻塞 read 改 poll+2s超时(agent-214) + ams_drain_stdout 64KB有界 + reap_wait兜底5处裸waitpid + watchdog关继承fd + font_sha256_file popen改有界 + 既有警告清理; fix(ncm): cookie盐不随包名(旧登录态可解)

launcher 97c1b222→333d6f53; ncm→1124dbf2; 宿主harness stall/ok/orphan全过
This commit is contained in:
MeowOS committed 2026-08-31 13:36:23 +08:00
1 parent efbd1d5a2f
commit 228e9e79e0
7 files changed
+86 -48

No files matched your search

+16 -17
View File
@@ -353,6 +353,7 @@ void meow_font_reload_multifont(void)
/* 计算文件 sha256(走 busybox/宿主 sha256sum;输出小写 64hex)。返回 0 成功。 */
static int font_sha256_file(const char *path, char *out, int olen)
{
if (!out || olen <= 0) return -1;
out[0] = 0;
/* 单引号转义防 shell 注入(路径含 ' 时安全;转义后超长则截断 → sha256sum 失败走 WARN) */
char esc[1024]; int j = 0;
@@ -363,24 +364,22 @@ static int font_sha256_file(const char *path, char *out, int olen)
esc[j] = 0;
char cmd[1080];
snprintf(cmd, sizeof cmd, "sha256sum '%s' 2>/dev/null", esc);
FILE *f = popen(cmd, "r");
if (!f) return -1;
char line[160];
int ok = -1;
if (fgets(line, sizeof line, f)) {
int i = 0, k = 0;
while (line[i] == ' ' || line[i] == '\t') i++; /* 跳前导空白 */
while (line[i] && k < 64) {
char c = line[i++];
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
out[k++] = c;
else break;
}
out[k] = 0;
ok = (k == 64) ? 0 : -1;
/* M2.84-bugfix:禁止裸 popen+fgets——sha256sum 在卡慢/挂起时可能长时间不返回,
* fgets 会阻塞在 pipe_wait(主循环卡死、电源键无响应)。改用有界 popen_read_tmo
* (O_NONBLOCK + poll + 超时,超时 SIGKILL 子进程),绝不阻塞主循环。 */
char *o = popen_read_tmo(1500, cmd);
if (!o) return -1;
int i = 0, k = 0;
while (o[i] == ' ' || o[i] == '\t') i++; /* 跳前导空白 */
while (o[i] && k < 64 && k + 1 < olen) {
char c = o[i++];
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
out[k++] = c;
else break;
}
pclose(f);
return ok;
out[k] = 0;
free(o);
return (k == 64) ? 0 : -1;
}