Skip to content

Commit

Permalink
Merge pull request #55876 from tensorflow/r2.6-13d38a07ce9
Browse files Browse the repository at this point in the history
r2.6 cherry-pick: 13d38a0 "Fix tf.raw_ops.UnsortedSegmentJoin vulnerability with invalid num_segments."
  • Loading branch information
mihaimaruseac committed May 4, 2022
2 parents f33b5ef + 0a7bd11 commit d379e5c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tensorflow/core/kernels/unsorted_segment_join_op.cc
Expand Up @@ -92,6 +92,9 @@ class UnsortedSegmentJoinOp : public OpKernel {
const Tensor& num_segments_tensor = context->input(2);
OP_REQUIRES(context, num_segments_tensor.NumElements() != 0,
errors::InvalidArgument("Number of segments cannot be empty."));
OP_REQUIRES(context,
TensorShapeUtils::IsScalar(num_segments_tensor.shape()),
errors::InvalidArgument("Number of segments must be a scalar"));
auto num_segments = num_segments_tensor.scalar<NUM_SEGMENTS_TYPE>()();

OP_REQUIRES(context, segment_dims != 0,
Expand Down

0 comments on commit d379e5c

Please sign in to comment.