summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Huth <huth@tuxfamily.org>2022-10-19 04:16:58 (GMT)
committerThomas Huth <huth@tuxfamily.org>2022-10-19 04:16:58 (GMT)
commit08f10f4e728a67d6e72e5193460f0efc1e995bea (patch)
treeea5284649bfba7eb78f9663122b2d1e1b033bb28
parent8ae54c453856b7e4462902ee9bce927b36e11fc5 (diff)
downloadhatari-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.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/file.c b/src/file.c
index 00fa469..2ca6923 100644
--- a/src/file.c
+++ b/src/file.c
@@ -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;
}
}