Skip to content

Commit

Permalink
Security Fuzz Test Fixes (#21608)
Browse files Browse the repository at this point in the history
### 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. -->
  • Loading branch information
jingyanwangms authored Aug 11, 2024
1 parent 6ae7e02 commit 154084e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions onnxruntime/core/framework/tensorprotoutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,7 @@ common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& n
common::Status ConstantNodeProtoToTensorProto(const ONNX_NAMESPACE::NodeProto& node,
const std::filesystem::path& model_path,
ONNX_NAMESPACE::TensorProto& tensor) {
ORT_ENFORCE(node.output_size() == 1, "NodeProto for Constant should have 1 output. Got:", node.output_size());
return ConstantNodeProtoToTensorProto(node, model_path, tensor, node.output(0));
}

Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/optimizer/unsqueeze_elimination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Status UnsqueezeElimination::Apply(Graph& graph, Node& node, RewriteRuleEffect&
// Generate new dims.
InlinedVector<int64_t> new_dims(output_rank, 0);
for (int64_t axis : axes) {
if (static_cast<size_t>(axis) >= new_dims.size()) {
LOGS(logger, WARNING) << "UnsqueezeElimination cannot remove node due to invalid axes" << node.Name();
return Status::OK();
}
new_dims[static_cast<size_t>(axis)] = 1;
}

Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/cpu/quantization/qlinearconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ Status QLinearConv<ActType>::PrePack(const Tensor& tensor, int input_idx, Alloca
const int64_t M = shape[0];
const int64_t C = shape[1];

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

Expand Down

0 comments on commit 154084e

Please sign in to comment.