mirror of https://github.com/OpenTTD/OpenTTD
(svn r3379) -Fix: protect showhelp against any possible overflow
-Add: [ FS#15 ] Added revision / version at top of help (./openttd -h)release/0.4.5
parent
79ce0def50
commit
835cd6ea28
13
driver.c
13
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;
|
const DriverClass* dc;
|
||||||
|
int pos;
|
||||||
|
|
||||||
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) {
|
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) {
|
||||||
const DriverDesc* dd;
|
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++) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
2
driver.h
2
driver.h
|
@ -8,6 +8,6 @@ void LoadDriver(int driver, const char *name);
|
||||||
bool GetDriverParamBool(const char* const* parm, const char* name);
|
bool GetDriverParamBool(const char* const* parm, const char* name);
|
||||||
int GetDriverParamInt(const char* const* parm, const char* name, int def);
|
int GetDriverParamInt(const char* const* parm, const char* name, int def);
|
||||||
|
|
||||||
void GetDriverList(char* p);
|
int GetDriverList(char* p, int size);
|
||||||
|
|
||||||
#endif /* DRIVER_H */
|
#endif /* DRIVER_H */
|
||||||
|
|
23
openttd.c
23
openttd.c
|
@ -115,11 +115,21 @@ void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
static void showhelp(void)
|
static void showhelp(void)
|
||||||
{
|
{
|
||||||
char buf[4096], *p;
|
char buf[4096], *p;
|
||||||
|
int size, pos;
|
||||||
|
|
||||||
p = strecpy(buf,
|
p = buf;
|
||||||
|
size = sizeof(buf);
|
||||||
|
|
||||||
|
pos = snprintf(p, size, "OpenTTD %s\n", _openttd_revision);
|
||||||
|
p += pos; size -= pos;
|
||||||
|
pos = snprintf(p, size,
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
"Command line options:\n"
|
"Command line options:\n"
|
||||||
" -v drv = Set video driver (see below)\n"
|
" -v drv = Set video driver (see below)\n"
|
||||||
" -s drv = Set sound driver (see below)\n"
|
" -s drv = Set sound driver (see below)\n"
|
||||||
|
@ -136,13 +146,14 @@ static void showhelp(void)
|
||||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
||||||
" -f = Fork into the background (dedicated only)\n"
|
" -f = Fork into the background (dedicated only)\n"
|
||||||
#endif
|
#endif
|
||||||
" -i = Force to use the DOS palette (use this if you see a lot of pink)\n"
|
" -i = Force to use the DOS palette\n"
|
||||||
" -p #player = Player as #player (deprecated) (network only)\n"
|
" (use this if you see a lot of pink)\n"
|
||||||
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n",
|
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
|
||||||
lastof(buf)
|
"\n"
|
||||||
);
|
);
|
||||||
|
p += pos; size -= pos;
|
||||||
|
|
||||||
GetDriverList(p);
|
size = GetDriverList(p, size);
|
||||||
|
|
||||||
ShowInfo(buf);
|
ShowInfo(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue