summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-06 01:23:25 +0000
committerrubidium <rubidium@openttd.org>2009-03-06 01:23:25 +0000
commit34bd9ee636b43d1851d27f92884769f8f25717be (patch)
tree8972c2c7b9b1ab7c2b41b46cd9a44f1bb0fbd9bd /src/saveload
parent9c6d6c0d0edba265c73c04901d0f2155173407b8 (diff)
downloadopenttd-34bd9ee636b43d1851d27f92884769f8f25717be.tar.xz
(svn r15626) -Fix [FS#2698]: UTF8 string handling could cause buffer overruns.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/oldloader.cpp1
-rw-r--r--src/saveload/saveload.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp
index 7def93796..6912ca9b5 100644
--- a/src/saveload/oldloader.cpp
+++ b/src/saveload/oldloader.cpp
@@ -232,6 +232,7 @@ static inline bool CheckOldSavegameType(FILE *f, char *temp, const char *last, u
bool ret = VerifyOldNameChecksum(temp, len);
temp[len - 2] = '\0'; // name is nul-terminated in savegame, but it's better to be sure
+ str_validate(temp, last);
return ret;
}
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 31f3b3c2d..390f36b3c 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -33,6 +33,7 @@
#include "../statusbar_gui.h"
#include "../fileio_func.h"
#include "../gamelog.h"
+#include "../string_func.h"
#include "table/strings.h"
@@ -631,6 +632,7 @@ static void SlString(void *ptr, size_t length, VarType conv)
}
((char*)ptr)[len] = '\0'; // properly terminate the string
+ str_validate((char*)ptr, (char*)ptr + len);
}
}