1 Star 0 Fork 14

ZJAY998/libiscsi

forked from src-openEuler/libiscsi 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0017-Updata-iscsi-dd.c.patch 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
From 8592dc58838872d0d49c3d773df950f0b3e1eb4b Mon Sep 17 00:00:00 2001
From: sallyjunjun <72725839+sallyjunjun@users.noreply.github.com>
Date: Tue, 31 May 2022 14:20:43 +0800
Subject: [PATCH 1/4] Update iscsi-dd.c
add check after malloc to avoid referencing an illegal pointer
---
examples/iscsi-dd.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/examples/iscsi-dd.c b/examples/iscsi-dd.c
index b2d41ac..1f7ae9f 100644
--- a/examples/iscsi-dd.c
+++ b/examples/iscsi-dd.c
@@ -131,6 +131,11 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void *
}
wt = malloc(sizeof(struct write_task));
+ if (wt == NULL) {
+ fprintf(stderr, "failed to alloc write task\n");
+ exit(10);
+ }
+
wt->rt = task;
wt->client = client;
@@ -430,6 +435,11 @@ void cscd_ident_inq(struct iscsi_context *iscsi,
_tgt_desig->designator_type = tgt_desig->designator_type;
_tgt_desig->designator_length = tgt_desig->designator_length;
_tgt_desig->designator = malloc(tgt_desig->designator_length);
+ if (_tgt_desig->designator == NULL) {
+ fprintf(stderr, "failed to alloc designator\n");
+ exit(10);
+ }
+
memcpy(_tgt_desig->designator, tgt_desig->designator, tgt_desig->designator_length);
scsi_free_scsi_task(task);
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zjay998/libiscsi.git
git@gitee.com:zjay998/libiscsi.git
zjay998
libiscsi
libiscsi
master

搜索帮助