Verify HudSetParams input when hotbar textures are set (#6013)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 19 Jun 2017 12:10:30 +0000 (14:10 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
* Verify HudSetParams input when hotbar textures are set

This fix #6011

src/network/clientpackethandler.cpp

index 59669fe6d0b933c2eabe8d333a117bca7c8cf2da..8935ed90cf90bc1e232c21368b448d7c497c3f8f 100644 (file)
@@ -1172,9 +1172,21 @@ void Client::handleCommand_HudSetParam(NetworkPacket* pkt)
                        player->hud_hotbar_itemcount = hotbar_itemcount;
        }
        else if (param == HUD_PARAM_HOTBAR_IMAGE) {
+               // If value not empty verify image exists in texture source
+               if (value != "" && !getTextureSource()->isKnownSourceImage(value)) {
+                       errorstream << "Server sent wrong Hud hotbar image (sent value: '"
+                               << value << "')" << std::endl;
+                       return;
+               }
                player->hotbar_image = value;
        }
        else if (param == HUD_PARAM_HOTBAR_SELECTED_IMAGE) {
+               // If value not empty verify image exists in texture source
+               if (value != "" && !getTextureSource()->isKnownSourceImage(value)) {
+                       errorstream << "Server sent wrong Hud hotbar selected image (sent value: '"
+                                       << value << "')" << std::endl;
+                       return;
+               }
                player->hotbar_selected_image = value;
        }
 }