aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/3.3.5/2020_08_17_02_world.sql6
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp14
2 files changed, 20 insertions, 0 deletions
diff --git a/sql/updates/world/3.3.5/2020_08_17_02_world.sql b/sql/updates/world/3.3.5/2020_08_17_02_world.sql
new file mode 100644
index 00000000000..b850fd391e2
--- /dev/null
+++ b/sql/updates/world/3.3.5/2020_08_17_02_world.sql
@@ -0,0 +1,6 @@
+--
+DELETE FROM `command` WHERE `name`='debug asan outofbounds';
+INSERT INTO `command` (`name`,`permission`,`help`) VALUES
+('debug asan outofbounds',874,'Syntax: .debug asan outofbounds
+Triggers a stack out of bounds read.
+Use only when testing dynamic analysis tools.');
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 5b6b85490d4..b4775d94857 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -81,6 +81,7 @@ public:
static std::vector<ChatCommand> debugAsanCommandTable =
{
{ "memoryleak", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugMemoryLeak, "" },
+ { "outofbounds", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugOutOfBounds, "" },
};
static std::vector<ChatCommand> debugCommandTable =
{
@@ -1704,10 +1705,23 @@ public:
return true;
}
+ static bool HandleDebugOutOfBounds(ChatHandler* handler, CommandArgs* /*args*/)
+ {
+#ifdef ASAN
+ uint8 stack_array[10] = {};
+ int size = 10;
+
+ handler->PSendSysMessage("Triggered an array out of bounds read at address %p, value %u", stack_array + size, stack_array[size]);
+#endif
+ return true;
+ }
+
static bool HandleDebugMemoryLeak(ChatHandler* handler)
{
+#ifdef ASAN
uint8* leak = new uint8();
handler->PSendSysMessage("Leaked 1 uint8 object at address %p", leak);
+#endif
return true;
}