Skip to content

Excel::__construct() no longer accepts an empty path after memory-safety fix #596

Description

@Appla

Commit 39e872089342bd14935ebd173466bd7c533f7b98 changed Vtiful\Kernel\Excel::__construct() to reject an empty $config['path'].

Previously, an empty string was accepted by the constructor. The change was introduced to prevent an out-of-bounds read in xls_file_path():

if (Z_STRVAL_P(dir_path)[Z_STRLEN_P(dir_path) - 1] == '/') {

When the path is empty, subtracting one from the unsigned string length underflows and may read outside the string buffer.

However, xls_file_path() now has a direct length guard:

if (Z_STRLEN_P(dir_path) > 0 &&
    Z_STRVAL_P(dir_path)[Z_STRLEN_P(dir_path) - 1] == '/') {

Therefore, rejecting the empty string in the constructor is no longer necessary for memory safety and introduces a backward-compatibility break.

Would it be possible to restore compatibility with an empty path? Alternatively, could the empty path be deprecated in the current version and rejected in the next major version?

I have prepared two branches demonstrating both approaches: Compatible, Deprecated

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions