forked from freeciv/freeciv-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON: avoid integer underflow in dir in orders.
Reported by Lexxie See osdn #42595
- Loading branch information
1 parent
c5d4c85
commit b5d9e7a
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
freeciv/patches/0001-JSON-avoid-integer-underflow-on-orders.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From 0e7309cd1645feb250df3fb211dacb1a23006b61 Mon Sep 17 00:00:00 2001 | ||
From: Sveinung Kvilhaugsvik <[email protected]> | ||
Date: Fri, 2 Jul 2021 10:02:30 +0200 | ||
Subject: [PATCH] JSON: avoid integer underflow in dir in orders. | ||
|
||
Reported by Lexxie | ||
|
||
See osdn #42595 | ||
--- | ||
common/networking/dataio_json.c | 7 ++++++- | ||
1 file changed, 6 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/common/networking/dataio_json.c b/common/networking/dataio_json.c | ||
index 90eb2a2996..8f8d67a853 100644 | ||
--- a/common/networking/dataio_json.c | ||
+++ b/common/networking/dataio_json.c | ||
@@ -289,7 +289,12 @@ void dio_put_unit_order_json(struct json_data_out *dout, | ||
json_object_set_new(obj, "target", json_integer(order->target)); | ||
json_object_set_new(obj, "sub_target", json_integer(order->sub_target)); | ||
json_object_set_new(obj, "action", json_integer(order->action)); | ||
- json_object_set_new(obj, "dir", json_integer(order->dir)); | ||
+ if (order->dir == -1) { | ||
+ /* Avoid integer underflow */ | ||
+ json_object_set_new(obj, "dir", json_integer(-1)); | ||
+ } else { | ||
+ json_object_set_new(obj, "dir", json_integer(order->dir)); | ||
+ } | ||
plocation_write_data(dout->json, location, obj); | ||
} else { | ||
dio_put_unit_order_raw(&dout->raw, order); | ||
-- | ||
2.30.2 | ||
|