代码拉取完成,页面将自动刷新
同步操作将从 openEuler-RISC-V/tensorflow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 701cfaca222a82afbeeb17496bd718baa65a67d2 Mon Sep 17 00:00:00 2001
From: Robert Neale <rneale@google.com>
Date: Tue, 26 Oct 2021 16:50:02 -0700
Subject: [PATCH] Fix heap out of bounds error in
tf.raw_ops.SparseCountSparseOutput shape inference when it is called with
invalid inputs, and add a test for it.
PiperOrigin-RevId: 405766415
Change-Id: I77d244ef35f351ef7b6f821efd959cac2c66db24
---
tensorflow/core/ops/count_ops.cc | 2 ++
tensorflow/python/ops/bincount_ops_test.py | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/tensorflow/core/ops/count_ops.cc b/tensorflow/core/ops/count_ops.cc
index 4f9631310df92..aa6c0437337af 100644
--- a/tensorflow/core/ops/count_ops.cc
+++ b/tensorflow/core/ops/count_ops.cc
@@ -41,6 +41,8 @@ Status DenseCountSparseOutputShapeFn(InferenceContext *c) {
}
Status SparseCountSparseOutputShapeFn(InferenceContext *c) {
+ ShapeHandle unused;
+ TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &unused));
auto rank = c->Dim(c->input(0), 1);
auto nvals = c->UnknownDim();
c->set_output(0, c->Matrix(nvals, rank)); // out.indices
diff --git a/tensorflow/python/ops/bincount_ops_test.py b/tensorflow/python/ops/bincount_ops_test.py
index 3c7a2a5da9daf..de7d1423870d7 100644
--- a/tensorflow/python/ops/bincount_ops_test.py
+++ b/tensorflow/python/ops/bincount_ops_test.py
@@ -831,6 +831,25 @@ def test_ragged_input_different_shape_fails(self):
self.evaluate(bincount_ops.sparse_bincount(x, weights=weights, axis=-1))
+class RawOpsHeapOobTest(test.TestCase, parameterized.TestCase):
+
+ @test_util.run_v1_only("Test security error")
+ def testSparseCountSparseOutputBadIndicesShapeTooSmall(self):
+ indices = [1]
+ values = [[1]]
+ weights = []
+ dense_shape = [10]
+ with self.assertRaisesRegex(ValueError,
+ "Shape must be rank 2 but is rank 1 for"):
+ self.evaluate(
+ gen_count_ops.SparseCountSparseOutput(
+ indices=indices,
+ values=values,
+ dense_shape=dense_shape,
+ weights=weights,
+ binary_output=True))
+
+
@test_util.run_all_in_graph_and_eager_modes
@test_util.disable_tfrt
class RawOpsTest(test.TestCase, parameterized.TestCase):
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。