From 441ac326235aec235aa1246402a7ae7b120687d2 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 6 Oct 2026 03:44:08 +0000 Subject: [PATCH] Handle the situation when connect_daemon returns -1 Fix #10117, close #10141 --- native/src/core/deny/cli.cpp | 4 +++- native/src/core/su/su.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/native/src/core/deny/cli.cpp b/native/src/core/deny/cli.cpp index e7c75b4fd..624b6ee39 100644 --- a/native/src/core/deny/cli.cpp +++ b/native/src/core/deny/cli.cpp @@ -97,7 +97,9 @@ int denylist_cli(rust::Vec &args) { } // Send request - int fd = connect_daemon(RequestCode::DENYLIST); + owned_fd fd = connect_daemon(RequestCode::DENYLIST); + if (fd < 0) exit(1); + write_int(fd, req); if (req == DenyRequest::ADD || req == DenyRequest::REMOVE) { write_string(fd, argv[1]); diff --git a/native/src/core/su/su.cpp b/native/src/core/su/su.cpp index 7c97d1295..b80a28038 100644 --- a/native/src/core/su/su.cpp +++ b/native/src/core/su/su.cpp @@ -210,6 +210,7 @@ end: // Connect to client owned_fd fd = connect_daemon(RequestCode::SUPERUSER); + if (fd < 0) exit(1); // Send request req.write_to_fd(fd);