aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinila S <106367904+vinila21@users.noreply.github.com>2022-08-25 19:01:48 -0700
committerGitHub <noreply@github.com>2022-08-25 19:01:48 -0700
commitf419a4148661172e322725c77e22c1ea07c17ff9 (patch)
tree3a93e697b33b0c6b165deb7bb1766d44d5f538e7
parent7067519293cf3bd18e07b6994b0b59920d1cf153 (diff)
downloadtensorflow-f419a4148661172e322725c77e22c1ea07c17ff9.tar.gz
Revert "r2.10 cherry-pick: e9863e9a9cb "Fix tf.raw_ops.EmptyTensorList vulnerability from non scalar `num_elements`.""
-rw-r--r--tensorflow/core/kernels/list_kernels.cc7
-rw-r--r--tensorflow/python/kernel_tests/data_structures/list_ops_test.py10
2 files changed, 0 insertions, 17 deletions
diff --git a/tensorflow/core/kernels/list_kernels.cc b/tensorflow/core/kernels/list_kernels.cc
index 72443a594c8..9648a43c919 100644
--- a/tensorflow/core/kernels/list_kernels.cc
+++ b/tensorflow/core/kernels/list_kernels.cc
@@ -31,11 +31,9 @@ limitations under the License.
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
-#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/framework/variant.h"
#include "tensorflow/core/framework/variant_op_registry.h"
-#include "tensorflow/core/platform/errors.h"
namespace tensorflow {
@@ -324,11 +322,6 @@ class TensorListReserve : public OpKernel {
void Compute(OpKernelContext* c) override {
PartialTensorShape element_shape;
OP_REQUIRES_OK(c, TensorShapeFromTensor(c->input(0), &element_shape));
- OP_REQUIRES(
- c, TensorShapeUtils::IsScalar(c->input(1).shape()),
- errors::InvalidArgument(
- "The num_elements to reserve must be a tensor size 1, but got ",
- c->input(1).shape()));
int32_t num_elements = c->input(1).scalar<int32>()();
OP_REQUIRES(c, num_elements >= 0,
errors::InvalidArgument("The num_elements to reserve must be a "
diff --git a/tensorflow/python/kernel_tests/data_structures/list_ops_test.py b/tensorflow/python/kernel_tests/data_structures/list_ops_test.py
index 2661e99fbe5..801372dce26 100644
--- a/tensorflow/python/kernel_tests/data_structures/list_ops_test.py
+++ b/tensorflow/python/kernel_tests/data_structures/list_ops_test.py
@@ -94,16 +94,6 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase):
l = list_ops.tensor_list_pop_back(l, element_dtype=dtypes.float32)
self.evaluate(l)
- def testTensorListReserveWithNonScalarNumElements(self):
- with self.assertRaisesRegex(
- errors.InvalidArgumentError,
- r"The num_elements to reserve must be a tensor size 1, but got \[2\]"):
- l = list_ops.tensor_list_reserve(
- element_dtype=dtypes.float32,
- element_shape=[2, 3],
- num_elements=constant_op.constant([1, 1]))
- self.evaluate(l)
-
def testPopUninitializedTensorUseListElementShape(self):
l = list_ops.tensor_list_reserve(
element_dtype=dtypes.float32, element_shape=[2, 3], num_elements=3)