s3:vfs_streams_xattr: avoid SIGFPE in streams_xattr_get_ea_value_fsp

After commit 5fa43440 ("vfs: Implement larger streams in multiple xattrs") a division by zero occurs in streams_xattr_get_ea_value_fsp, leading to a SIGFPE and a crash.

This is because of the overflow check for attr_size:

        if (attr_size > (SIZE_MAX / config->max_extents)) {
                return EOVERFLOW;

The default value of config->max_extents is zero, since it is set to max_xattrs - 1 in streams_xattr_connect (in the same file), while max_xattrs is the value of the streams_xattr:max xattrs per stream option, which has a default of 1.

To avoid crashing with division by zero, check explicitly that config->max_extents is larger than zero.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16278

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional) This MR is just one part towards a larger feature.
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code

Merge request reports

Loading
Loading