diff options
author | rubidium <rubidium@openttd.org> | 2015-05-20 18:18:26 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2015-05-20 18:18:26 +0000 |
commit | 10466746b4083d93af547c153db3730e74c8a3a2 (patch) | |
tree | 8b316537337fedf6d7f8cfef7e5374cbc58520e5 /src | |
parent | d05ac99d52e8051a5ec75393863b44cca17306b3 (diff) | |
download | openttd-10466746b4083d93af547c153db3730e74c8a3a2.tar.xz |
(svn r27290) -Fix: sanitize the command line arguments before doing anything complex with them
Diffstat (limited to 'src')
-rw-r--r-- | src/os/os2/os2.cpp | 3 | ||||
-rw-r--r-- | src/os/unix/unix.cpp | 5 | ||||
-rw-r--r-- | src/os/windows/win32.cpp | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index eb3671029..386cc4dbb 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -174,6 +174,9 @@ int CDECL main(int argc, char *argv[]) { SetRandomSeed(time(NULL)); + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); + return openttd_main(argc, argv); } diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 59d40cc89..24dedb2ee 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -259,7 +259,8 @@ void cocoaReleaseAutoreleasePool(); int CDECL main(int argc, char *argv[]) { - int ret; + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); #ifdef WITH_COCOA cocoaSetupAutoreleasePool(); @@ -275,7 +276,7 @@ int CDECL main(int argc, char *argv[]) signal(SIGPIPE, SIG_IGN); - ret = openttd_main(argc, argv); + int ret = openttd_main(argc, argv); #ifdef WITH_COCOA cocoaReleaseAutoreleasePool(); diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 3d5f0ebde..f69f01f6c 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -453,6 +453,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi argc = ParseCommandLine(cmdline, argv, lengthof(argv)); + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); + openttd_main(argc, argv); free(cmdline); return 0; |