tensorflow/CVE-2021-29546.patch

25 lines
1.1 KiB
Diff
Raw Normal View History

From 67784700869470d65d5f2ef20aeb5e97c31673cb Mon Sep 17 00:00:00 2001
From: Mihai Maruseac <mihaimaruseac@google.com>
Date: Fri, 23 Apr 2021 11:11:39 -0700
Subject: [PATCH] Prevent division by 0 in `QuantizedBiasAdd`.
PiperOrigin-RevId: 370117454
Change-Id: I3804e2ac8dcc6d3afcc92e27853e2325a017ca4d
---
tensorflow/core/kernels/quantized_bias_add_op.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tensorflow/core/kernels/quantized_bias_add_op.cc b/tensorflow/core/kernels/quantized_bias_add_op.cc
index 5457d290c2559..db0e21a498011 100644
--- a/tensorflow/core/kernels/quantized_bias_add_op.cc
+++ b/tensorflow/core/kernels/quantized_bias_add_op.cc
@@ -56,6 +56,8 @@ class QuantizedBiasAddOp : public OpKernel {
"Must provide as many biases as the last dimension "
"of the input tensor: ",
bias.shape().DebugString(), " vs. ", input.shape().DebugString()));
+ OP_REQUIRES(context, bias.NumElements() > 0,
+ errors::InvalidArgument("Must provide at least 1 bias"));
Tensor* output = nullptr;
OP_REQUIRES_OK(context,