Skip to content

Commit

Permalink
Do not accept empty inputs when filling cfTempPath (from $TEMP), and …
Browse files Browse the repository at this point in the history
…ensure that it ends with a slash
  • Loading branch information
mywave82 committed Sep 14, 2024
1 parent 54b201a commit 507aea2
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions boot/psetting.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,18 +698,31 @@ int cfGetConfig(int argc, char *argv[])
cfDataPath = strdup (t);
}

if ((t=_cfGetProfileString("general", "tempdir", t)))
t=_cfGetProfileString("general", "tempdir", 0);
if (!t || !strlen (t))
{
cfTempPath = strdup (t);
} else if ((t=getenv("TEMP")))
t=getenv("TEMP");
}
if (!t || !strlen (t))
{
cfTempPath = strdup (t);
} else if ((t=getenv("TMP")))
t=getenv("TMP");
}
if (!t || !strlen (t))
{
cfTempPath = strdup (t);
} else {
cfTempPath = strdup ("/tmp/");
#ifdef _WIN32
t = "c:\\TEMP\\";
#else
t = "/tmp/";
#endif
}
cfTempPath = malloc (strlen (t) + 2);
#ifdef _WIN32
# define c "\\"
#else
# define c "/"
#endif
sprintf (cfTempPath, "%s%s", t, (t[strlen(t) - 1] != c[0]) ? c : "");
#undef c

#ifdef PSETTING_DEBUG
{
Expand Down

0 comments on commit 507aea2

Please sign in to comment.