googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[Bug]: Stack overflow in CreateDirectoriesRecursively

Open elupus opened this issue 1 year ago • 0 comments

Describe the issue

Asking google test to output to a non existing path, on a system with no notion of "./" being a path causes FilePath::CreateDirectoriesRecursively to end up in an infinite loop with stack overflow.

Steps to reproduce the problem

Somewhat hard.

  • Run on an embedded system with file support, but no concept on a current directory named "./".
  • Ask google-test to output xml to a non existing path.

What version of GoogleTest are you using?

609281088cfefc76f9d0ce82e1ff6c30cc3591e5

Its also patch in a small way to work around: https://github.com/google/googletest/issues/1372

What operating system and version are you using?

rt-kernel

What compiler and version are you using?

arm-eabi-gcc (rt-collab toolbox 2022.1-0-gf81ad3e) 10.4.0

What build system are you using?

cmake version 3.25.0

Additional context

When creating directories recursively the stop condition is an empty pathname: https://github.com/google/googletest/blob/04cf2989168a3f9218d463bea6f15f8ade2032fd/googletest/src/gtest-filepath.cc#L338

However, RemoveFileName() function will never end up with an empty pathname, but a ./ separator. https://github.com/google/googletest/blob/04cf2989168a3f9218d463bea6f15f8ade2032fd/googletest/src/gtest-filepath.cc#L215

elupus avatar Jun 01 '23 08:06 elupus