summaryrefslogtreecommitdiff
path: root/driver.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-01-06 22:52:31 +0000
committertruelight <truelight@openttd.org>2006-01-06 22:52:31 +0000
commit30232bf428c8979667138a4b3ed2058cbe9fef9d (patch)
treebcbe71fd499d92db668ecf04b5e0a41fd2226d96 /driver.c
parent5e68953907d4859cdefa6dd521a1996a86ae4c49 (diff)
downloadopenttd-30232bf428c8979667138a4b3ed2058cbe9fef9d.tar.xz
(svn r3379) -Fix: protect showhelp against any possible overflow
-Add: [ FS#15 ] Added revision / version at top of help (./openttd -h)
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/driver.c b/driver.c
index 0595e4397..998f8a90d 100644
--- a/driver.c
+++ b/driver.c
@@ -206,16 +206,23 @@ int GetDriverParamInt(const char* const* parm, const char* name, int def)
}
-void GetDriverList(char* p)
+int GetDriverList(char* p, int size)
{
const DriverClass* dc;
+ int pos;
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) {
const DriverDesc* dd;
- p += sprintf(p, "List of %s drivers:\n", dc->name);
+ pos = snprintf(p, size, "List of %s drivers:\n", dc->name);
+ p += pos; size -= pos;
for (dd = dc->descs; dd->name != NULL; dd++) {
- p += sprintf(p, "%10s: %s\n", dd->name, dd->longname);
+ pos = snprintf(p, size, "%10s: %s\n", dd->name, dd->longname);
+ p += pos; size -= pos;
}
+ pos = snprintf(p, size, "\n");
+ p += pos; size -= pos;
}
+
+ return size;
}