google / google/googletest

[Bug]: Stack overflow in CreateDirectoriesRecursively

Open
#4,262 0 comments 1 reaction 1 assignee Claimed by @asoffer View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.