Ai
1 Star 0 Fork 57

gice/tensorflow

forked from openEuler-RISC-V/tensorflow
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2021-29535.patch 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
From efea03b38fb8d3b81762237dc85e579cc5fc6e87 Mon Sep 17 00:00:00 2001
From: Mihai Maruseac <mihaimaruseac@google.com>
Date: Wed, 21 Apr 2021 16:15:46 -0700
Subject: [PATCH] Validate inputs to `QuantizedMul`
PiperOrigin-RevId: 369756982
Change-Id: I00d960cc3b9316fd7a86bd37a44e341c96e17624
---
tensorflow/core/kernels/quantized_mul_op.cc | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/tensorflow/core/kernels/quantized_mul_op.cc b/tensorflow/core/kernels/quantized_mul_op.cc
index fb56f68bf14db..22cff8939449a 100644
--- a/tensorflow/core/kernels/quantized_mul_op.cc
+++ b/tensorflow/core/kernels/quantized_mul_op.cc
@@ -284,10 +284,22 @@ class QuantizedMulOp : public OpKernel {
void Compute(OpKernelContext* context) override {
const Tensor& x = context->input(0);
const Tensor& y = context->input(1);
- const float min_x = context->input(2).flat<float>()(0);
- const float max_x = context->input(3).flat<float>()(0);
- const float min_y = context->input(4).flat<float>()(0);
- const float max_y = context->input(5).flat<float>()(0);
+ auto& min_x_tensor = context->input(2);
+ OP_REQUIRES(context, TensorShapeUtils::IsScalar(min_x_tensor.shape()),
+ errors::InvalidArgument("min_x must be a scalar"));
+ const float min_x = min_x_tensor.flat<float>()(0);
+ auto& max_x_tensor = context->input(3);
+ OP_REQUIRES(context, TensorShapeUtils::IsScalar(max_x_tensor.shape()),
+ errors::InvalidArgument("max_x must be a scalar"));
+ const float max_x = max_x_tensor.flat<float>()(0);
+ auto& min_y_tensor = context->input(4);
+ OP_REQUIRES(context, TensorShapeUtils::IsScalar(min_y_tensor.shape()),
+ errors::InvalidArgument("min_y must be a scalar"));
+ const float min_y = min_y_tensor.flat<float>()(0);
+ auto& max_y_tensor = context->input(5);
+ OP_REQUIRES(context, TensorShapeUtils::IsScalar(max_y_tensor.shape()),
+ errors::InvalidArgument("max_y must be a scalar"));
+ const float max_y = max_y_tensor.flat<float>()(0);
BCast bcast(BCast::FromShape(x.shape()), BCast::FromShape(y.shape()));
if (!bcast.IsValid()) {
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gice/tensorflow.git
git@gitee.com:gice/tensorflow.git
gice
tensorflow
tensorflow
master

搜索帮助