summaryrefslogtreecommitdiff
path: root/unix.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-01-31 12:08:49 +0000
committerpeter1138 <peter1138@openttd.org>2006-01-31 12:08:49 +0000
commit0ad6dc9cc246d71920aec028616fd21994967788 (patch)
treefb209c59882db9fea045debd6dbd9b5ce7a9f708 /unix.c
parentee889951eaa71290a5caab7d0987a238357f5090 (diff)
downloadopenttd-0ad6dc9cc246d71920aec028616fd21994967788.tar.xz
(svn r3496) - Validate filename titles before they get displayed. This avoids crashes with UTF-8 encoded or bad filenames by replacing undisplayable characters with a '?'
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/unix.c b/unix.c
index 7e23aca00..192337ef3 100644
--- a/unix.c
+++ b/unix.c
@@ -121,6 +121,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
snprintf(fios->title, lengthof(fios->title),
"%s/ (Directory)", dirent->d_name);
+ str_validate(fios->title);
}
}
closedir(dir);
@@ -163,6 +164,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
*t = '\0'; // strip extension
ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
+ str_validate(fios->title);
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
if (strcasecmp(t, ".ss1") == 0 ||
strcasecmp(t, ".sv1") == 0 ||
@@ -222,6 +224,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
fios->mtime = 0;
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
snprintf(fios->title, lengthof(fios->title), "%s/ (Directory)", dirent->d_name);
+ str_validate(fios->title);
}
}
closedir(dir);
@@ -262,6 +265,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
*t = '\0'; // strip extension
ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
+ str_validate(fios->title);
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
mode == SLD_NEW_GAME) {
if (strcasecmp(t, ".sv0") == 0 ||