Changeset - r26312:295bdfcc9944
[Not reviewed]
master
0 2 0
Patric Stout - 2 years ago 2022-07-09 10:27:58
truebrain@openttd.org
Fix: CmdRemoveRoadStop didn't validate the height property properly (#9945)

Height was a unsigned 32bit integer, where TileAddWrap uses a
signed 32bit integer for the height. In result, there was an
implicit cast from unsigned to signed, messing things up.

But looking at it from a functional perspective, allowing such
large values is not sensible. In fact, width is restricted to
just a 8bit integer. By changing height to a 8bit integer too,
the implicit cast will never make a positive value negative anymore.
2 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -2058,7 +2058,7 @@ static CommandCost RemoveRoadStop(TileIn
 
 * @param remove_road Remove roads of drive-through stops?
 
 * @return The cost of this operation or an error.
 
 */
 
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint height, RoadStopType stop_type, bool remove_road)
 
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
 
{
 
	if (stop_type >= ROADSTOP_END) return CMD_ERROR;
 
	/* Check for incorrect width / height. */
src/station_cmd.h
Show inline comments
 
@@ -20,7 +20,7 @@ CommandCost CmdBuildDock(DoCommandFlag f
 
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent);
 
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
 
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, StationID station_to_join, bool adjacent);
 
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint height, RoadStopType stop_type, bool remove_road);
 
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road);
 
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text);
 
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id);
 

	
0 comments (0 inline, 0 general)