diff options
| author | Thomas Huth <huth@tuxfamily.org> | 2022-10-19 04:16:58 (GMT) |
|---|---|---|
| committer | Thomas Huth <huth@tuxfamily.org> | 2022-10-19 04:16:58 (GMT) |
| commit | 08f10f4e728a67d6e72e5193460f0efc1e995bea (patch) | |
| tree | ea5284649bfba7eb78f9663122b2d1e1b033bb28 | |
| parent | 8ae54c453856b7e4462902ee9bce927b36e11fc5 (diff) | |
| download | hatari-08f10f4e728a67d6.zip hatari-08f10f4e728a67d6.tar.gz | |
Fix File_MakeValidPathName() for inputs that point to a place in the root dir
Thanks to Andreas Grabher for the hint!
| -rw-r--r-- | src/file.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -954,6 +954,9 @@ void File_MakeValidPathName(char *pPathName) struct stat dirstat; char *pLastSlash; + if (!pPathName[0]) + return; /* Avoid writing to zero-size buffers */ + do { /* Check for a valid path */ @@ -970,12 +973,9 @@ void File_MakeValidPathName(char *pPathName) } else { - if (pPathName[0]) - { - /* point to root */ - pPathName[0] = PATHSEP; - pPathName[1] = 0; - } + /* point to root */ + pPathName[0] = PATHSEP; + pPathName[1] = 0; return; } } |
