1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-09 13:41:43 +00:00

dmnt2: try to avoid writing out of bounds when generating packets

This commit is contained in:
Michael Scire 2021-11-02 10:09:15 -07:00
parent d30af4763a
commit be5cd35ef6
4 changed files with 261 additions and 235 deletions

View file

@ -50,9 +50,9 @@ namespace ams::osdbg {
} else { } else {
/* Special-case libnx threads. */ /* Special-case libnx threads. */
if (thread_info->_thread_type_type == ThreadTypeType_Libnx) { if (thread_info->_thread_type_type == ThreadTypeType_Libnx) {
util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_%p", reinterpret_cast<void *>(thread_info->_thread_type)); util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_0x%010lx", reinterpret_cast<uintptr_t>(thread_info->_thread_type));
} else { } else {
util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_%p", reinterpret_cast<void *>(thread_info->_thread_type)); util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_0x%010lx", reinterpret_cast<uintptr_t>(thread_info->_thread_type));
} }
return ResultSuccess(); return ResultSuccess();

View file

@ -601,9 +601,9 @@ namespace ams::dmnt {
if (R_FAILED(osdbg::GetThreadName(dst, std::addressof(m_thread_infos[i])))) { if (R_FAILED(osdbg::GetThreadName(dst, std::addressof(m_thread_infos[i])))) {
if (m_thread_infos[i]._thread_type != 0) { if (m_thread_infos[i]._thread_type != 0) {
if (m_thread_infos[i]._thread_type_type == osdbg::ThreadTypeType_Libnx) { if (m_thread_infos[i]._thread_type_type == osdbg::ThreadTypeType_Libnx) {
util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_%p", reinterpret_cast<void *>(m_thread_infos[i]._thread_type)); util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_0x%010lx", reinterpret_cast<uintptr_t>(m_thread_infos[i]._thread_type));
} else { } else {
util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_%p", reinterpret_cast<void *>(m_thread_infos[i]._thread_type)); util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_0x%010lx", reinterpret_cast<uintptr_t>(m_thread_infos[i]._thread_type));
} }
} else { } else {
break; break;

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,8 @@ namespace ams::dmnt {
TransportSession m_session; TransportSession m_session;
GdbPacketIo m_packet_io; GdbPacketIo m_packet_io;
char *m_receive_packet{nullptr}; char *m_receive_packet{nullptr};
char *m_reply_packet{nullptr}; char *m_reply_cur{nullptr};
char *m_reply_end{nullptr};
char m_buffer[GdbPacketBufferSize / 2]; char m_buffer[GdbPacketBufferSize / 2];
bool m_killed{false}; bool m_killed{false};
os::ThreadType m_events_thread; os::ThreadType m_events_thread;
@ -61,7 +62,7 @@ namespace ams::dmnt {
static void DebugEventsThreadEntry(void *arg) { static_cast<GdbServerImpl *>(arg)->DebugEventsThread(); } static void DebugEventsThreadEntry(void *arg) { static_cast<GdbServerImpl *>(arg)->DebugEventsThread(); }
void DebugEventsThread(); void DebugEventsThread();
void ProcessDebugEvents(); void ProcessDebugEvents();
void SetStopReplyPacket(GdbSignal signal); void AppendStopReplyPacket(GdbSignal signal);
private: private:
void D(); void D();