Fix record type width in badtls writeRecordLocked

This commit is contained in:
世界
2026-11-27 19:59:58 +08:00
parent 89d4eea09c
commit 593b9b2e6b
5 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -171,6 +171,6 @@ func (c *RawConn) HandlePostHandshakeMessage() error {
return c.methods.handlePostHandshakeMessage(c.pointer)
}
func (c *RawConn) WriteRecordLocked(typ uint16, data []byte) (int, error) {
func (c *RawConn) WriteRecordLocked(typ uint8, data []byte) (int, error) {
return c.methods.writeRecordLocked(c.pointer, typ, data)
}
+2 -2
View File
@@ -17,7 +17,7 @@ var _ *tls.Conn
type Methods struct {
readRecord func(c unsafe.Pointer) error
handlePostHandshakeMessage func(c unsafe.Pointer) error
writeRecordLocked func(c unsafe.Pointer, typ uint16, data []byte) (int, error)
writeRecordLocked func(c unsafe.Pointer, typ uint8, data []byte) (int, error)
setErrorLocked func(hc unsafe.Pointer, err error) error
decrypt func(hc unsafe.Pointer, record []byte) ([]byte, uint8, error)
@@ -53,7 +53,7 @@ func stdTLSReadRecord(c unsafe.Pointer) error
func stdTLSHandlePostHandshakeMessage(c unsafe.Pointer) error
//go:linkname stdWriteRecordLocked crypto/tls.(*Conn).writeRecordLocked
func stdWriteRecordLocked(c unsafe.Pointer, typ uint16, data []byte) (int, error)
func stdWriteRecordLocked(c unsafe.Pointer, typ uint8, data []byte) (int, error)
//go:linkname stdSetErrorLocked crypto/tls.(*halfConn).setErrorLocked
func stdSetErrorLocked(hc unsafe.Pointer, err error) error
+1 -1
View File
@@ -41,7 +41,7 @@ func utlsReadRecord(c unsafe.Pointer) error
func utlsHandlePostHandshakeMessage(c unsafe.Pointer) error
//go:linkname utlsWriteRecordLocked github.com/metacubex/utls.(*Conn).writeRecordLocked
func utlsWriteRecordLocked(hc unsafe.Pointer, typ uint16, data []byte) (int, error)
func utlsWriteRecordLocked(hc unsafe.Pointer, typ uint8, data []byte) (int, error)
//go:linkname utlsSetErrorLocked github.com/metacubex/utls.(*halfConn).setErrorLocked
func utlsSetErrorLocked(hc unsafe.Pointer, err error) error
+2 -2
View File
@@ -287,7 +287,7 @@ func (c *Conn) readKernelRecord() (uint8, []byte, error) {
return recordTypeApplicationData, data[:n], nil
}
func (c *Conn) writeKernelRecord(typ uint16, data []byte) (int, error) {
func (c *Conn) writeKernelRecord(typ uint8, data []byte) (int, error) {
if typ == recordTypeApplicationData {
return c.conn.Write(data)
}
@@ -296,7 +296,7 @@ func (c *Conn) writeKernelRecord(typ uint16, data []byte) (int, error) {
buffer := make([]byte, unix.CmsgSpace(1))
cmsg := (*unix.Cmsghdr)(unsafe.Pointer(&buffer[0]))
cmsg.SetLen(unix.CmsgLen(1))
buffer[unix.CmsgLen(0)] = byte(typ)
buffer[unix.CmsgLen(0)] = typ
cmsg.Level = unix.SOL_TLS
cmsg.Type = TLS_SET_RECORD_TYPE
+1 -1
View File
@@ -73,7 +73,7 @@ func (c *Conn) Write(b []byte) (int, error) {
return n + m, c.rawConn.Out.SetErrorLocked(err)
}
func (c *Conn) writeRecordLocked(typ uint16, data []byte) (n int, err error) {
func (c *Conn) writeRecordLocked(typ uint8, data []byte) (n int, err error) {
if !c.kernelTx {
return c.rawConn.WriteRecordLocked(typ, data)
}