https://bugs.documentfoundation.org/show_bug.cgi?id=173964

            Bug ID: 173964
           Summary: Assertion failure in Dir() when accessing /c directory
                    on Unix
           Product: LibreOffice
           Version: 27.2.0.0 alpha0+ master
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Version:
LibreOffice development version (master branch, built from source).

The issue was observed on the master branch.

LibreOffice Basic's Dir() function can trigger an assertion failure when
accessing a directory named "/c" at the root of a Unix filesystem.

Steps to Reproduce:
1. On a Unix/Linux system, create a directory named "/c":
   sudo mkdir /c

2. Start LibreOffice.
3. Open the Basic macro editor.
4. Execute the following macro:

   Sub Main
       s = Dir$("file:///c/*", 16)
   End Sub

Actual Results:
LibreOffice triggers an assertion failure.

Expected Results:
LibreOffice should handle "/c" as a regular Unix directory without triggering
an assertion failure.

Technical Details:
The issue is related to the isRootDir() function in
basic/source/runtime/methods.cxx

When a URL contains exactly one path segment, the function accesses aSeg1[1]
without checking whether the segment contains at least two characters.

For a single-character directory name such as "/c", this results in an
out-of-bounds access.

Proposed Fix:
Check the segment length before accessing its second character.

The issue was identified during a code simplification patch submitted to
Gerrit. A separate bugfix patch will be submitted to allow backporting to
stable branches.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to