mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-17 20:57:27 +00:00
fix: resolve postgres startup message length type mismatch and uint underflow OOM risk (#10065)
* fix: resolve postgres startup message length type mismatch and uint underflow OOM risk * Update weed/server/postgres/server.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: wangmeijuan <542204218@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
wangmeijuan
gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent
b0bad761ff
commit
aeaf62fa86
@@ -388,7 +388,13 @@ func (s *PostgreSQLServer) handleStartup(session *PostgreSQLSession) error {
|
||||
return fmt.Errorf("failed to read message length during startup: %v", err)
|
||||
}
|
||||
|
||||
msgLength := binary.BigEndian.Uint32(length) - 4
|
||||
msgTotalLen := binary.BigEndian.Uint32(length)
|
||||
// Prevent unsigned underflow and OOM by checking total message length first
|
||||
if msgTotalLen < 8 {
|
||||
return fmt.Errorf("startup message too short: %d bytes", msgTotalLen)
|
||||
}
|
||||
|
||||
msgLength := msgTotalLen - 4
|
||||
if msgLength > 10000 { // Reasonable limit for startup messages
|
||||
return fmt.Errorf("startup message too large: %d bytes", msgLength)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user