mirror of
https://github.com/minetest/minetest.git
synced 2024-11-29 19:13:44 +01:00
Sanitize invalid particle spawner time (#15465)
This commit is contained in:
parent
11b19cd126
commit
b77ad82fb9
@ -270,6 +270,7 @@ ParticleSpawner::ParticleSpawner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t max_particles = 0; // maximum number of particles likely to be visible at any given time
|
size_t max_particles = 0; // maximum number of particles likely to be visible at any given time
|
||||||
|
assert(p.time >= 0);
|
||||||
if (p.time != 0) {
|
if (p.time != 0) {
|
||||||
auto maxGenerations = p.time / std::min(p.exptime.start.min, p.exptime.end.min);
|
auto maxGenerations = p.time / std::min(p.exptime.start.min, p.exptime.end.min);
|
||||||
max_particles = p.amount / maxGenerations;
|
max_particles = p.amount / maxGenerations;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
|
|
||||||
|
#include "exceptions.h"
|
||||||
#include "irr_v2d.h"
|
#include "irr_v2d.h"
|
||||||
#include "util/base64.h"
|
#include "util/base64.h"
|
||||||
#include "client/camera.h"
|
#include "client/camera.h"
|
||||||
@ -1007,6 +1008,8 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt)
|
|||||||
|
|
||||||
p.amount = readU16(is);
|
p.amount = readU16(is);
|
||||||
p.time = readF32(is);
|
p.time = readF32(is);
|
||||||
|
if (p.time < 0)
|
||||||
|
throw SerializationError("particle spawner time < 0");
|
||||||
|
|
||||||
bool missing_end_values = false;
|
bool missing_end_values = false;
|
||||||
if (m_proto_ver >= 42) {
|
if (m_proto_ver >= 42) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
|
||||||
#include "lua_api/l_particles.h"
|
#include "lua_api/l_particles.h"
|
||||||
|
#include "common/c_types.h"
|
||||||
#include "lua_api/l_object.h"
|
#include "lua_api/l_object.h"
|
||||||
#include "lua_api/l_internal.h"
|
#include "lua_api/l_internal.h"
|
||||||
#include "lua_api/l_particleparams.h"
|
#include "lua_api/l_particleparams.h"
|
||||||
@ -280,6 +281,9 @@ int ModApiParticles::l_add_particlespawner(lua_State *L)
|
|||||||
p.node_tile = getintfield_default(L, 1, "node_tile", p.node_tile);
|
p.node_tile = getintfield_default(L, 1, "node_tile", p.node_tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.time < 0)
|
||||||
|
throw LuaError("particle spawner 'time' must be >= 0");
|
||||||
|
|
||||||
u32 id = getServer(L)->addParticleSpawner(p, attached, playername);
|
u32 id = getServer(L)->addParticleSpawner(p, attached, playername);
|
||||||
lua_pushnumber(L, id);
|
lua_pushnumber(L, id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user