add: error handling for UpdateMountNamespace

This commit adds the missing error handling for "UpdateMountNamespace" in both libzygisk.so and ReZygiskd, as before it would send a -1 as unsigned, leading to issues.
This commit is contained in:
ThePedroo
2025-04-25 02:02:29 -03:00
parent a460c54d08
commit a4c9794de0
2 changed files with 19 additions and 2 deletions

View File

@@ -647,8 +647,17 @@ void zygiskd_start(char *restrict argv[]) {
save_mns_fd(pid, Module, impl);
}
uint32_t clean_namespace_fd = (uint32_t)save_mns_fd(pid, (enum MountNamespaceState)mns_state, impl);
ret = write_uint32_t(client_fd, clean_namespace_fd);
int clean_namespace_fd = save_mns_fd(pid, (enum MountNamespaceState)mns_state, impl);
if (clean_namespace_fd == -1) {
LOGE("Failed to save mount namespace fd for pid %d: %s\n", pid, strerror(errno));
ret = write_uint32_t(client_fd, (uint32_t)0);
ASSURE_SIZE_WRITE_BREAK("UpdateMountNamespace", "clean_namespace_fd", ret, sizeof(clean_namespace_fd));
break;
}
ret = write_uint32_t(client_fd, (uint32_t)clean_namespace_fd);
ASSURE_SIZE_WRITE_BREAK("UpdateMountNamespace", "clean_namespace_fd", ret, sizeof(clean_namespace_fd));
break;