Commit graph

33042 commits

Author SHA1 Message Date
Jyrki Vesterinen
6450bada57 Lua: delete loadstring()
Fixes the vulnerability introduced in commit 52ae31efb2.
2018-07-28 08:16:00 +03:00
Jyrki Vesterinen
52ae31efb2 Lua: implement our own load() instead of monkey-patching Lua code
Monkey-patching has multiple problems. The biggest problem for a security
fix like this is that it's way too easy to forget to re-apply when we
update Lua to a newer version.

Instead, we now have the implementation of load() under our control and can
update Lua without risk of reintroducing CVE-2018-1999023.
2018-07-27 15:36:56 +03:00
gfgtdf
2554c166dd disallow loading lua bytecode via load/dofile (CVE-2018-1999023)
This could otherwise be used to escape the lua sandbox, as described in
multiple sources. For example one can use it to reenable the os.execute
function to do shell commands

The affected functions were
load,loadstring,wesnoth.dofile,wesnoth.require and various places in the
wesnoth source where lua chunks were loaded for example by the ai code.

This commit also changes the lua source to change luas load (which is
the same as loadstring), alternatively we could add a wrapper around the
original load function that always passes "t" as third parameter, i went
this way mostly because it was easier to implement, but also because i
was not 100% sure that is is impossible to query the upvalues of a
function via lua (wesnoth disables debug.getupvalue but still).

There is also an occurance in the application_lua_kernel that was not fixed
because i assumed that umc cannot contian application lua scipts.

As further security measure we might want to disable printing the function
adress in luas tostring for c functions, this cannot be exploited by itself
but it can be used to defeat ASLR in some cases.
2018-07-27 15:36:56 +03:00
Jyrki Vesterinen
e961cc0899 Fix: we negate an unsigned integer
Negating an unsigned integer still returns an unsigned value
(in other words, always positive) which isn't what we want.
2018-07-27 11:35:54 +03:00
jostephd
6e31c83c64 Fix sorting of units by level in Recall List and Unit List (#3370)
Now the triangle points down when the list is sorted by level descending.
2018-07-27 10:29:02 +03:00
ProditorMagnus
625f18ab2e Make /q sl and status case insensitive 2018-07-24 22:26:30 +03:00
Toom
aab10daac4 Show "failed to fit" message with single timestamp (#3367)
Before:

20180724 17:21:37 error gui/layout: Failed to fit vertical list to requested rect; expected bottom edge was 277
20180724 17:21:37 error gui/layout: , actual bottom edge was 195
20180724 17:21:37 error gui/layout:  (top edge is 113)

After:

20180724 17:34:30 error gui/layout: Failed to fit vertical list to requested rect; expected bottom edge was 277, actual bottom edge was 195 (top edge is 113)
2018-07-24 17:57:05 +03:00
Jyrki Vesterinen
d8e2498dde Create a named struct for terrain name and movement pair
This allows the sorting logic top be shared between the sidebar and the
unit preview pane. It also means that we no longer need to create a lambda
to sort them.

I also refactored the generation of movement cost data in help. In
particular, we're no longer extracting the struct to named local variables.
2018-07-23 17:25:24 +03:00
lilinitsy
61b7e7298b Sort the movement costs in the tooltip in ascending order (#3305)
Sort movement costs in tooltip, unit preview pane, and unit description alphabetically.
2018-07-23 17:16:56 +03:00
Iris Morelle
bb86afcb72 gui2/unit_recall: Fix i18n issues
The original commit adding the Rename Unit button marked two strings in
the C++ source for extraction without making them translatable.
2018-07-22 07:30:46 -04:00
Martin Hrubý (hrubymar10)
bc4d22dc72 Migrate links to https if available - Fwd c18537edc0 2018-07-16 19:07:08 +11:00
Łukasz Hryniuk
349b18b216 gui2: allow renaming units in the Recall dialog 2018-07-16 08:16:51 +11:00
Celtic Minstrel
45674a3d79 Fix AI ignoring teleport locations when moving leader to leader goals 2018-07-15 10:56:17 -04:00
Celtic Minstrel
99233339dd wesnoth.find_path: Allow specifying custom flags (in particular teleport) when using a custom cost function 2018-07-15 10:56:17 -04:00
josteph
af71bfe9c7 WML: Support the the 'jamming' key in [unit].
This syntax is already in use in the test scenario.
2018-07-15 09:43:05 -04:00
Charles Dang
06c723636a Fixed base64 images not being translated to textures 2018-07-15 21:33:00 +11:00
Charles Dang
300197e9c0 GUI2/Dispatcher: pass the message parameter for message events around as const
Really no reason for it to be non-const. That would imply the message's contents should
be modifiable, but that doesn't make sense.
2018-07-15 16:49:49 +11:00
Charles Dang
b47b6f1359 GUI2/Dispatcher: simplified callback function aliases with an alias template
This guarantees all events have the same initial four parameters. Also improved documentation.
2018-07-15 15:49:37 +11:00
gfgtdf
08d907e570 add a comment 2018-07-14 16:57:37 +11:00
Charles Dang
c0b09315d1 Language Selection: declared an execute function 2018-07-14 16:20:34 +11:00
Charles Dang
637e69f271 Used the return value of modal_dialog::show instead of an explicit retval check when possible 2018-07-14 16:17:59 +11:00
Charles Dang
85e9b40495 GUI2: added/renamed widget data types aliases
Also moved the string_map alias into the GUI2 namespace and renamed it widget_item.
It's the same as utils::string_map, but this makes its purpose clearer.
2018-07-14 16:07:12 +11:00
Charles Dang
e62ec5f806 GUI2/Tree View: use NOTIFY_MODIFIED events instead of manual callbacks
Unlike other widgets where `this` is the event target, the tree nodes fire the event
with the tree widget itself as the target.

I had added a fire-event call in f97dc8ae12, but with
the target as the node. I don't think there was any way that would have worked...
changed.
2018-07-14 12:09:06 +11:00
Charles Dang
996551e6f7 GUI2/Tree View [Node]: formatting cleanup 2018-07-14 11:54:35 +11:00
Charles Dang
8da9f0cc04 GUI2/Tree View Node: used std::make_shared when possible
Child nodes were still managed with unique_ptrs in 1.14, so we couldn't use make_unique
there. Child nodes are now managed with shared_ptrs here on master.
2018-07-14 06:38:08 +11:00
Charles Dang
ae7d05e8fc MP Staging: move side nodes when changing teams instead of recreating them
Mp Join Game will require further refactoring; it recreates the entire tree when receiving data...
2018-07-14 06:32:44 +11:00
Charles Dang
fa7c967c0a GUI2/Tree View: added interface for moving nodes between parent nodes 2018-07-14 06:32:43 +11:00
Charles Dang
8fcd3f2a83 Reapply d0100758f8 2018-07-13 21:02:13 +11:00
Charles Dang
264389807c Upgrade to Lua 5.3.5 2018-07-13 21:02:12 +11:00
Charles Dang
8abb1965cb Fixup f7cf733 again 2018-07-13 18:30:52 +11:00
Charles Dang
64067dde09 Attempt to fixup f7cf733
Also made the map generator array static
2018-07-13 18:19:37 +11:00
Charles Dang
f7cf73307b Convert some more C arrays to std::array 2018-07-13 16:15:00 +11:00
Charles Dang
4c29a0dd58 Use '\t' instead of static_cast<char>(9) 2018-07-13 15:53:20 +11:00
Charles Dang
ce85c17020 Convert a few remaining C-style casts (for char) too static_cast 2018-07-13 15:48:20 +11:00
Jyrki Vesterinen
95f19745ca Fix #2813: wrong chat color after a side is unassigned from a player
Regression from commit 36e9290.

As @gfgtdf pointed out in the bug report, because old_player was a
reference to the shared_ptr, resetting the shared_ptr in sides_ also
changed old_player, and thus 'the player lost his last side' check never
passed.

Thanks to @gfgtdf for figuring out the cause.
2018-07-12 07:35:19 +03:00
Jyrki Vesterinen
1699c0d3f9 Fix #2789: lobby chat scrolls to top on new messages if not at bottom 2018-07-10 19:54:34 +03:00
Charles Dang
60950a797f Unit Recall: marked some sorting options as translatable
This matches Unit List.
2018-07-09 14:48:03 +11:00
Charles Dang
94db6ba8c5 Unit List/Unit Recall: simplified level sorting functionality 2018-07-09 14:47:24 +11:00
Charles Dang
c41da8255d GUI2: cleaned up a whole bunch of widget-related includes
gui/widgets/settings.hpp was rendered unnecessary in almost all dialog and widget files
as of 6759f41b1e, since it was no longer needed to implement
the internal functions wrapped by the REGISTER_DIALOG and REGISTER_WIDGET macros. Those
were register_window() and register_widget(), respectively.
2018-07-09 13:42:05 +11:00
Charles Dang
19c78fc1c2 Help: removed an unnecessary use of t_string as a map key 2018-07-09 08:03:44 +11:00
josteph
dcbdac8ab5 Help: only use male_name/female_name if the unit has male/female variants. 2018-07-08 15:54:54 +11:00
josteph
a4b0de5ece Help: Use female_name and name as fallback when male_name is empty and don't list hidden traits.
This algorithm was lifted from help::generate_trait_topics().

Fixes #3284
2018-07-08 15:54:41 +11:00
Jyrki Vesterinen
00d8548c24 Damage prediction: round very close slow probabilities to 0 or 1
In the case in bug #3321, damage prediction code somehow receives a
combatant whose probability to be slowed is very close to one of those
values but not quite it. I couldn't figure out how it's possible because
only damage prediction code itself is supposed to emit slow probabilities,
and it's not producing such a probability in this case.

Without more information, I'm simply fixing the bug by force. If the
probability is in the problematic area, we simply round it to 0 or 1. This
way such probabilities are impossible later on when we try to scale the HP
distributions so that they add to 1.

Fixes #3321.
2018-07-06 22:55:14 +03:00
Celtic Minstrel
41e757be9f Fix incorrect formatting of probabilities in the sidebar
This resulted from an incorrect use of std::setprecision, which sets the number of significant figures to display, not the number of decimal places.
2018-07-05 12:49:12 +11:00
Choicerer
02bdd17994 Fix team chat not being marked on remote clients (#3314)
Fixing the lack of stars on the remote client when sending a team/observer message.
This commit didn't modify the necessary lines in replay.cpp:
6aa3b3b
(of which the chat_msg::chat_msg one has already been fixed)

Fixes #3119
2018-07-05 12:46:43 +11:00
Charles Dang
e2fd9749a6 Re-enable the --new-widgets tests for general dialogs 2018-07-03 04:44:13 +11:00
Charles Dang
458dd284b8 GUI2: removed 2010 experimental listbox
This was never finished, is not maintained, suffers from a lack of features the "old" listbox
class now has, and seems (according to the logs) to be have been superceded by the pane widget.
At the very least, the pane widget seems to be what mordante was working with in his early
prototype of a new addon manager, and not this 2010 list class.
2018-07-02 22:22:17 +11:00
Charles Dang
9fe86315f5 GUI2: dropped a remaining t-prefix from a type 2018-07-02 13:08:48 +11:00
Charles Dang
6cc3d1427c Disable in-game HUD for now
Need to sort out the problems with dispatching events to the HUD or the gamemap, respectively.
Disabling the HUD for now so it should be possible to interact with the map in case someone
wants to work on its rendering.
2018-07-01 23:41:08 +11:00
Jyrki Vesterinen
d8eada856a Fix build 2018-06-30 10:57:42 +03:00