home · contact · privacy
Server/py: Add value check to command_turn().
authorChristian Heller <c.heller@plomlompom.de>
Tue, 24 Feb 2015 01:46:55 +0000 (02:46 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 24 Feb 2015 01:46:55 +0000 (02:46 +0100)
plomrogue-server.py

index 9e4f008a5198d58d3dc937456532eaf1480a482f..8d09550e7f97e419cece12ea9cf74f0a0bbb9325 100755 (executable)
@@ -252,7 +252,13 @@ def command_quit():
 
 def command_turn(turn_string):
     """Set turn to what's described in turn_string."""
-    world_db["TURN"] = int(turn_string)
+    try:
+        turn = int(turn_string)
+        if turn < 0 or turn > 65535:
+            raise ValueError
+        world_db["TURN"] = turn
+    except ValueError:
+        print("Ignoring: Argument must be integer >= 0 and <= 65535.")
 
 
 """Commands database.