summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuipyowert2 <38995150+Quipyowert2@users.noreply.github.com>2020-02-20 16:30:36 -0800
committerCharles Pigott <charlespigott@googlemail.com>2020-02-23 19:04:34 +0000
commitd1b7eb2de1d79acfcae1e591cf66d95be6b5f5c7 (patch)
treeda983a10aab2868a2adb4c16b117a4ea77455030 /src
parenta4a6e5dfb43337625068d954c0b6834d33afc0a1 (diff)
downloadopenttd-d1b7eb2de1d79acfcae1e591cf66d95be6b5f5c7.tar.xz
Codechange: Limit field width to avoid sscanf crash
Diffstat (limited to 'src')
-rw-r--r--src/network/network.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e8c99c89b..0e3d08630 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -917,7 +917,8 @@ void NetworkGameLoop()
if (*p == ' ') p++;
cp = CallocT<CommandPacket>(1);
int company;
- int ret = sscanf(p, "%x; %x; %x; %x; %x; %x; %x; \"%[^\"]\"", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
+ assert_compile(sizeof(cp->text) == 128);
+ int ret = sscanf(p, "%x; %x; %x; %x; %x; %x; %x; \"%127[^\"]\"", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
/* There are 8 pieces of data to read, however the last is a
* string that might or might not exist. Ignore it if that
* string misses because in 99% of the time it's not used. */