Skip to content

Commit 154084e

Browse files
Security Fuzz Test Fixes (microsoft#21608)
### Description Fix address sanitizer and memory access Bug 1, 4, 5, 7, 8 found in security fuzz test ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
1 parent 6ae7e02 commit 154084e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

onnxruntime/core/framework/tensorprotoutils.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& n
13581358
common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& node,
13591359
const std::filesystem::path& model_path,
13601360
ONNX_NAMESPACE::TensorProto& tensor) {
1361+
ORT_ENFORCE(node.output_size() == 1, "NodeProto for Constant should have 1 output. Got:", node.output_size());
13611362
return ConstantNodeProtoToTensorProto(node, model_path, tensor, node.output(0));
13621363
}
13631364

onnxruntime/core/optimizer/unsqueeze_elimination.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Status UnsqueezeElimination::Apply(Graph& graph, Node& node, RewriteRuleEffect&
4040
// Generate new dims.
4141
InlinedVector<int64_t> new_dims(output_rank, 0);
4242
for (int64_t axis : axes) {
43+
if (static_cast<size_t>(axis) >= new_dims.size()) {
44+
LOGS(logger, WARNING) << "UnsqueezeElimination cannot remove node due to invalid axes" << node.Name();
45+
return Status::OK();
46+
}
4347
new_dims[static_cast<size_t>(axis)] = 1;
4448
}
4549

onnxruntime/core/providers/cpu/quantization/qlinearconv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ Status QLinearConv<ActType>::PrePack(const Tensor& tensor, int input_idx, Alloca
380380
const int64_t M = shape[0];
381381
const int64_t C = shape[1];
382382

383-
// Verify that the total number of output channels is a multiple of the group count.
384-
if (M % conv_attrs_.group != 0) {
383+
// Verify that conv_attrs_.group is not 0 and the total number of output channels is a multiple of the group count.
384+
if (conv_attrs_.group == 0 || M % conv_attrs_.group != 0) {
385385
return Status::OK();
386386
}
387387

0 commit comments

Comments
 (0)