From 589d83d4dadfb2794f4a7c040012751246ac0b68 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 09:30:36 -0800 Subject: [PATCH 1/6] http: Prevent assert on bad websocket data. --- Common/Net/Sinks.cpp | 6 ++++++ Common/Net/Sinks.h | 1 + Core/Debugger/WebSocket.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/Common/Net/Sinks.cpp b/Common/Net/Sinks.cpp index 2d15de15cf..a81d3ce998 100644 --- a/Common/Net/Sinks.cpp +++ b/Common/Net/Sinks.cpp @@ -164,6 +164,12 @@ bool InputSink::Skip(size_t bytes) { return true; } +void InputSink::Discard() { + read_ = 0; + write_ = 0; + valid_ = 0; +} + void InputSink::Fill() { // Avoid small reads if possible. if (BUFFER_SIZE - valid_ > PRESSURE) { diff --git a/Common/Net/Sinks.h b/Common/Net/Sinks.h index fa5546c917..e49630f57f 100644 --- a/Common/Net/Sinks.h +++ b/Common/Net/Sinks.h @@ -19,6 +19,7 @@ public: size_t TakeAtMost(char *buf, size_t bytes); // Skip exactly this number of bytes, or fail. bool Skip(size_t bytes); + void Discard(); bool Empty(); bool TryFill(); diff --git a/Core/Debugger/WebSocket.cpp b/Core/Debugger/WebSocket.cpp index 418c81188d..9c4cdeef3c 100644 --- a/Core/Debugger/WebSocket.cpp +++ b/Core/Debugger/WebSocket.cpp @@ -196,6 +196,7 @@ void HandleDebuggerRequest(const http::Request &request) { } delete ws; + request.In()->Discard(); UpdateConnected(-1); } From f19d957c42c50eb2bd0a43109960a6085aea9a91 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 09:31:30 -0800 Subject: [PATCH 2/6] Debugger: Cleanup memory.read/write validation. Required parameters fail automatically, better to keep the error consistent. This was sending two errors. Additionally, don't allow it when no game is started yet. --- Core/Debugger/WebSocket/MemorySubscriber.cpp | 37 ++++++++++---------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Core/Debugger/WebSocket/MemorySubscriber.cpp b/Core/Debugger/WebSocket/MemorySubscriber.cpp index 6710b7492c..a029469734 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.cpp +++ b/Core/Debugger/WebSocket/MemorySubscriber.cpp @@ -17,6 +17,7 @@ #include "Common/StringUtils.h" #include "Core/MemMap.h" +#include "Core/MIPS/MIPSDebugInterface.h" #include "Core/System.h" #include "Core/Debugger/WebSocket/MemorySubscriber.h" #include "Core/Debugger/WebSocket/WebSocketUtils.h" @@ -42,10 +43,11 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map) { // - value: unsigned integer void WebSocketMemoryReadU8(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } @@ -67,10 +69,11 @@ void WebSocketMemoryReadU8(DebuggerRequest &req) { // - value: unsigned integer void WebSocketMemoryReadU16(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } @@ -92,10 +95,11 @@ void WebSocketMemoryReadU16(DebuggerRequest &req) { // - value: unsigned integer void WebSocketMemoryReadU32(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } @@ -118,15 +122,14 @@ void WebSocketMemoryReadU32(DebuggerRequest &req) { // - value: new value, unsigned integer void WebSocketMemoryWriteU8(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr, val; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr, val; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } - if (!req.ParamU32("value", &val, false)) { - req.Fail("No value given"); return; } @@ -150,15 +153,14 @@ void WebSocketMemoryWriteU8(DebuggerRequest &req) { // - value: new value, unsigned integer void WebSocketMemoryWriteU16(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr, val; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr, val; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } - if (!req.ParamU32("value", &val, false)) { - req.Fail("No value given"); return; } @@ -182,15 +184,14 @@ void WebSocketMemoryWriteU16(DebuggerRequest &req) { // - value: new value, unsigned integer void WebSocketMemoryWriteU32(DebuggerRequest &req) { auto memLock = Memory::Lock(); - uint32_t addr, val; + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + uint32_t addr, val; if (!req.ParamU32("address", &addr, false)) { - req.Fail("No address given"); return; } - if (!req.ParamU32("value", &val, false)) { - req.Fail("No value given"); return; } From 7e5052bc9e59e18115e65739106cf4b63cfe1dc2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 10:30:58 -0800 Subject: [PATCH 3/6] Debugger: Add API to read/write chunks of memory. Using base64 at this point to keep JSON. --- Common/Data/Encoding/Base64.cpp | 45 +++++++++++ Common/Data/Encoding/Base64.h | 3 + Core/Debugger/WebSocket/MemorySubscriber.cpp | 82 ++++++++++++++++++++ Core/Debugger/WebSocket/MemorySubscriber.h | 2 + 4 files changed, 132 insertions(+) diff --git a/Common/Data/Encoding/Base64.cpp b/Common/Data/Encoding/Base64.cpp index 50dbc465a5..5d7e4512fb 100644 --- a/Common/Data/Encoding/Base64.cpp +++ b/Common/Data/Encoding/Base64.cpp @@ -33,3 +33,48 @@ std::string Base64Encode(const uint8_t *p, size_t sz) { return result; } + +std::vector Base64Decode(const char *s, size_t sz) { + const uint8_t lookup[256] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 63, 62, 255, 63, + // '0' starts here. + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 255, 255, 255, + // 'A' after an invalid. + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 63, + // 'a' after an invalid. + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, + }; + + std::vector result; + result.reserve(3 * sz / 4); + + for (size_t i = 0; i < sz; i += 4) { + uint8_t quad[4] = { + lookup[s[i]], + i + 1 < sz ? lookup[s[i + 1]] : 255, + i + 2 < sz ? lookup[s[i + 2]] : 255, + i + 3 < sz ? lookup[s[i + 3]] : 255, + }; + + // First: ABCDEF GHXXXX XXXXXX XXXXXX. Neither 6-bit value should be invalid. + result.push_back((quad[0] << 2) | ((quad[1] & 0x30) >> 4)); + + // Next: XXXXXX XXABCD EFGHXX XXXXXX. Invalid if quad[2] is invalid. + if (quad[2] == 255) { + continue; + } + result.push_back(((quad[1] & 0x0F) << 4) | ((quad[2] & 0x3C) >> 2)); + + // Last: XXXXXX XXXXXX XXXXAB CDEFGH. Invalid only if quad[3] is. + if (quad[3] == 255) { + continue; + } + result.push_back(((quad[2] & 0x03) << 6) | (quad[3] & 0x3F)); + } + + return result; +} diff --git a/Common/Data/Encoding/Base64.h b/Common/Data/Encoding/Base64.h index b963bfb391..dedd07906e 100644 --- a/Common/Data/Encoding/Base64.h +++ b/Common/Data/Encoding/Base64.h @@ -1,5 +1,8 @@ #pragma once +#include #include +#include std::string Base64Encode(const uint8_t *p, size_t sz); +std::vector Base64Decode(const char *s, size_t sz); diff --git a/Core/Debugger/WebSocket/MemorySubscriber.cpp b/Core/Debugger/WebSocket/MemorySubscriber.cpp index a029469734..20a612592c 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.cpp +++ b/Core/Debugger/WebSocket/MemorySubscriber.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include "Common/Data/Encoding/Base64.h" #include "Common/StringUtils.h" #include "Core/MemMap.h" #include "Core/MIPS/MIPSDebugInterface.h" @@ -27,9 +29,11 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map) { map["memory.read_u8"] = &WebSocketMemoryReadU8; map["memory.read_u16"] = &WebSocketMemoryReadU16; map["memory.read_u32"] = &WebSocketMemoryReadU32; + map["memory.read"] = &WebSocketMemoryRead; map["memory.write_u8"] = &WebSocketMemoryWriteU8; map["memory.write_u16"] = &WebSocketMemoryWriteU16; map["memory.write_u32"] = &WebSocketMemoryWriteU32; + map["memory.write"] = &WebSocketMemoryWrite; return nullptr; } @@ -112,6 +116,50 @@ void WebSocketMemoryReadU32(DebuggerRequest &req) { json.writeUint("value", Memory::Read_U32(addr)); } +// Read bytes from memory (memory.read) +// +// Parameters: +// - address: unsigned integer address for the start of the memory range. +// - size: unsigned integer specifying size of memory range. +// +// Response (same event name): +// - base64: base64 encode of binary data. +void WebSocketMemoryRead(DebuggerRequest &req) { + auto memLock = Memory::Lock(); + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + + uint32_t addr; + if (!req.ParamU32("address", &addr)) { + return; + } + uint32_t size; + if (!req.ParamU32("size", &size)) { + return; + } + + if (!Memory::IsValidAddress(addr)) { + return req.Fail("Invalid address"); + } else if (!Memory::IsValidRange(addr, size)) { + return req.Fail("Invalid size"); + } + + JsonWriter &json = req.Respond(); + // Start a value without any actual data yet... + json.writeRaw("base64", ""); + req.Flush(); + + // Now we'll write it directly to the stream. + req.ws->AddFragment(false, "\""); + // 65535 is an "even" number of base64 characters. + static const size_t CHUNK_SIZE = 65535; + for (size_t i = 0; i < size; i += CHUNK_SIZE) { + size_t left = std::min(size - i, CHUNK_SIZE); + req.ws->AddFragment(false, Base64Encode(Memory::GetPointerUnchecked(addr) + i, left)); + } + req.ws->AddFragment(false, "\""); +} + // Write a byte to memory (memory.write_u8) // // Parameters: @@ -204,3 +252,37 @@ void WebSocketMemoryWriteU32(DebuggerRequest &req) { JsonWriter &json = req.Respond(); json.writeUint("value", Memory::Read_U32(addr)); } + +// Write bytes to memory (memory.write) +// +// Parameters: +// - address: unsigned integer address for the start of the memory range. +// - base64: data to write, encoded as base64 string +// +// Response (same event name) with no extra data. +void WebSocketMemoryWrite(DebuggerRequest &req) { + auto memLock = Memory::Lock(); + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + + uint32_t addr; + if (!req.ParamU32("address", &addr)) { + return; + } + std::string encoded; + if (!req.ParamString("base64", &encoded)) { + return; + } + + std::vector value = Base64Decode(&encoded[0], encoded.size()); + uint32_t size = (uint32_t)value.size(); + + if (!Memory::IsValidAddress(addr)) { + return req.Fail("Invalid address"); + } else if (value.size() != (size_t)size || !Memory::IsValidRange(addr, size)) { + return req.Fail("Invalid size"); + } + + Memory::MemcpyUnchecked(addr, &value[0], size); + req.Respond(); +} diff --git a/Core/Debugger/WebSocket/MemorySubscriber.h b/Core/Debugger/WebSocket/MemorySubscriber.h index 32e8e898c0..4ffb76d8f5 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.h +++ b/Core/Debugger/WebSocket/MemorySubscriber.h @@ -24,6 +24,8 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map); void WebSocketMemoryReadU8(DebuggerRequest &req); void WebSocketMemoryReadU16(DebuggerRequest &req); void WebSocketMemoryReadU32(DebuggerRequest &req); +void WebSocketMemoryRead(DebuggerRequest &req); void WebSocketMemoryWriteU8(DebuggerRequest &req); void WebSocketMemoryWriteU16(DebuggerRequest &req); void WebSocketMemoryWriteU32(DebuggerRequest &req); +void WebSocketMemoryWrite(DebuggerRequest &req); From b5a669301901e9a8984c2146ab53821ce48ec448 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 10:46:05 -0800 Subject: [PATCH 4/6] Debugger: Add helper to read strings. This is common, so let's expose as an API. --- Core/Debugger/WebSocket/MemorySubscriber.cpp | 43 ++++++++++++++++++++ Core/Debugger/WebSocket/MemorySubscriber.h | 1 + 2 files changed, 44 insertions(+) diff --git a/Core/Debugger/WebSocket/MemorySubscriber.cpp b/Core/Debugger/WebSocket/MemorySubscriber.cpp index 20a612592c..d6f078fb7a 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.cpp +++ b/Core/Debugger/WebSocket/MemorySubscriber.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include #include "Common/Data/Encoding/Base64.h" #include "Common/StringUtils.h" #include "Core/MemMap.h" @@ -30,6 +31,7 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map) { map["memory.read_u16"] = &WebSocketMemoryReadU16; map["memory.read_u32"] = &WebSocketMemoryReadU32; map["memory.read"] = &WebSocketMemoryRead; + map["memory.readString"] = &WebSocketMemoryReadString; map["memory.write_u8"] = &WebSocketMemoryWriteU8; map["memory.write_u16"] = &WebSocketMemoryWriteU16; map["memory.write_u32"] = &WebSocketMemoryWriteU32; @@ -160,6 +162,47 @@ void WebSocketMemoryRead(DebuggerRequest &req) { req.ws->AddFragment(false, "\""); } +// Read a NUL terminated string from memory (memory.readString) +// +// Parameters: +// - address: unsigned integer address for the start of the memory range. +// - type: optional, 'utf-8' (default) or 'base64'. +// +// Response (same event name) for 'utf8': +// - value: string value read. +// +// Response (same event name) for 'base64': +// - base64: base64 encode of binary data, not including NUL. +void WebSocketMemoryReadString(DebuggerRequest &req) { + auto memLock = Memory::Lock(); + if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) + return req.Fail("CPU not started"); + + uint32_t addr; + if (!req.ParamU32("address", &addr)) + return; + std::string type = "utf-8"; + if (!req.ParamString("type", &type, DebuggerParamType::OPTIONAL)) + return; + if (type != "utf-8" && type != "base64") + return req.Fail("Invalid type, must be either utf-8 or base64"); + + if (!Memory::IsValidAddress(addr)) + return req.Fail("Invalid address"); + + // Let's try to avoid crashing and get a safe length. + const uint8_t *p = Memory::GetPointerUnchecked(addr); + size_t longest = Memory::ValidSize(addr, Memory::g_MemorySize); + size_t len = strnlen((const char *)p, longest); + + JsonWriter &json = req.Respond(); + if (type == "utf-8") { + json.writeString("value", std::string((const char *)p, len)); + } else if (type == "base64") { + json.writeString("base64", Base64Encode(p, len)); + } +} + // Write a byte to memory (memory.write_u8) // // Parameters: diff --git a/Core/Debugger/WebSocket/MemorySubscriber.h b/Core/Debugger/WebSocket/MemorySubscriber.h index 4ffb76d8f5..8dfb2ade7a 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.h +++ b/Core/Debugger/WebSocket/MemorySubscriber.h @@ -25,6 +25,7 @@ void WebSocketMemoryReadU8(DebuggerRequest &req); void WebSocketMemoryReadU16(DebuggerRequest &req); void WebSocketMemoryReadU32(DebuggerRequest &req); void WebSocketMemoryRead(DebuggerRequest &req); +void WebSocketMemoryReadString(DebuggerRequest &req); void WebSocketMemoryWriteU8(DebuggerRequest &req); void WebSocketMemoryWriteU16(DebuggerRequest &req); void WebSocketMemoryWriteU32(DebuggerRequest &req); From 3325a278113738e753b64f35714be203a437e34a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 11:13:54 -0800 Subject: [PATCH 5/6] Debugger: Cleanup some syntax. --- Common/Data/Encoding/Base64.cpp | 4 ++-- Core/Debugger/WebSocket/MemorySubscriber.cpp | 22 +++++++------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Common/Data/Encoding/Base64.cpp b/Common/Data/Encoding/Base64.cpp index 5d7e4512fb..6c82766338 100644 --- a/Common/Data/Encoding/Base64.cpp +++ b/Common/Data/Encoding/Base64.cpp @@ -2,7 +2,7 @@ // TODO: This is a simple but not very efficient implementation. std::string Base64Encode(const uint8_t *p, size_t sz) { - const char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + static const char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; size_t unpaddedLength = (4 * sz + 2) / 3; std::string result; @@ -35,7 +35,7 @@ std::string Base64Encode(const uint8_t *p, size_t sz) { } std::vector Base64Decode(const char *s, size_t sz) { - const uint8_t lookup[256] = { + static const uint8_t lookup[256] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 63, 62, 255, 63, diff --git a/Core/Debugger/WebSocket/MemorySubscriber.cpp b/Core/Debugger/WebSocket/MemorySubscriber.cpp index d6f078fb7a..8adc6fec5b 100644 --- a/Core/Debugger/WebSocket/MemorySubscriber.cpp +++ b/Core/Debugger/WebSocket/MemorySubscriber.cpp @@ -132,19 +132,16 @@ void WebSocketMemoryRead(DebuggerRequest &req) { return req.Fail("CPU not started"); uint32_t addr; - if (!req.ParamU32("address", &addr)) { + if (!req.ParamU32("address", &addr)) return; - } uint32_t size; - if (!req.ParamU32("size", &size)) { + if (!req.ParamU32("size", &size)) return; - } - if (!Memory::IsValidAddress(addr)) { + if (!Memory::IsValidAddress(addr)) return req.Fail("Invalid address"); - } else if (!Memory::IsValidRange(addr, size)) { + else if (!Memory::IsValidRange(addr, size)) return req.Fail("Invalid size"); - } JsonWriter &json = req.Respond(); // Start a value without any actual data yet... @@ -309,22 +306,19 @@ void WebSocketMemoryWrite(DebuggerRequest &req) { return req.Fail("CPU not started"); uint32_t addr; - if (!req.ParamU32("address", &addr)) { + if (!req.ParamU32("address", &addr)) return; - } std::string encoded; - if (!req.ParamString("base64", &encoded)) { + if (!req.ParamString("base64", &encoded)) return; - } std::vector value = Base64Decode(&encoded[0], encoded.size()); uint32_t size = (uint32_t)value.size(); - if (!Memory::IsValidAddress(addr)) { + if (!Memory::IsValidAddress(addr)) return req.Fail("Invalid address"); - } else if (value.size() != (size_t)size || !Memory::IsValidRange(addr, size)) { + else if (value.size() != (size_t)size || !Memory::IsValidRange(addr, size)) return req.Fail("Invalid size"); - } Memory::MemcpyUnchecked(addr, &value[0], size); req.Respond(); From 711dd0e8ace526463504074826d5145ef9c08251 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 Dec 2020 20:16:49 -0800 Subject: [PATCH 6/6] Debugger: Correct a type error. --- Common/Data/Encoding/Base64.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Common/Data/Encoding/Base64.cpp b/Common/Data/Encoding/Base64.cpp index 6c82766338..fbd77c0fac 100644 --- a/Common/Data/Encoding/Base64.cpp +++ b/Common/Data/Encoding/Base64.cpp @@ -49,15 +49,16 @@ std::vector Base64Decode(const char *s, size_t sz) { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255, }; + const uint8_t *p = (const uint8_t *)s; std::vector result; result.reserve(3 * sz / 4); for (size_t i = 0; i < sz; i += 4) { uint8_t quad[4] = { - lookup[s[i]], - i + 1 < sz ? lookup[s[i + 1]] : 255, - i + 2 < sz ? lookup[s[i + 2]] : 255, - i + 3 < sz ? lookup[s[i + 3]] : 255, + lookup[p[i]], + i + 1 < sz ? lookup[p[i + 1]] : (uint8_t)255, + i + 2 < sz ? lookup[p[i + 2]] : (uint8_t)255, + i + 3 < sz ? lookup[p[i + 3]] : (uint8_t)255, }; // First: ABCDEF GHXXXX XXXXXX XXXXXX. Neither 6-bit value should be invalid.