iSulad/0070-ensure-isulad_io-not-NULL-before-close-fd.patch
zhangxiaoyu 68738aa0f1 upgrade from upstream
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2023-06-01 12:04:54 +08:00

63 lines
1.8 KiB
Diff

From e485c54e69c42f1af056f47ac2e16d9cb2d03042 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sun, 14 May 2023 14:25:22 +0800
Subject: [PATCH 70/79] ensure isulad_io not NULL before close fd
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/cmd/isulad-shim/process.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index f1391ecb..aa3aa37c 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -194,6 +194,10 @@ static int stdin_cb(int fd, uint32_t events, void *cbdata, struct epoll_descr *d
} else {
fd_to = &(p->shim_io->in);
}
+
+ if (fd_to == NULL || *fd_to == -1) {
+ return EPOLL_LOOP_HANDLE_CONTINUE;
+ }
w_count = write_nointr_in_total(*fd_to, p->buf, r_count);
if (w_count < 0) {
/* When any error occurs, set the write fd -1 */
@@ -797,21 +801,21 @@ static int init_isulad_stdio(process_t *p)
return SHIM_OK;
failure:
if (p->isulad_io != NULL) {
+ if (p->isulad_io->in > 0) {
+ close(p->isulad_io->in);
+ }
+ if (p->isulad_io->out > 0) {
+ close(p->isulad_io->out);
+ }
+ if (p->isulad_io->err > 0) {
+ close(p->isulad_io->err);
+ }
+ if (p->isulad_io->resize > 0) {
+ close(p->isulad_io->resize);
+ }
free(p->isulad_io);
p->isulad_io = NULL;
}
- if (p->isulad_io->in > 0) {
- close(p->isulad_io->in);
- }
- if (p->isulad_io->out > 0) {
- close(p->isulad_io->out);
- }
- if (p->isulad_io->err > 0) {
- close(p->isulad_io->err);
- }
- if (p->isulad_io->resize > 0) {
- close(p->isulad_io->resize);
- }
return SHIM_ERR;
}
--
2.25.1