You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlexStocks (GitHub)" <gi...@apache.org> on 2020/02/29 10:20:30 UTC
[GitHub] [dubbo-go] AlexStocks opened issue #380: HessianCodec包头长度检查异常
func (h *HessianCodec) ReadHeader(header *DubboHeader) error {
var err error
if h.reader.Size() < HEADER_LENGTH {
return ErrHeaderNotEnough
}
buf, err := h.reader.Peek(HEADER_LENGTH)
if err != nil { // this is impossible
return perrors.WithStack(err)
}
...
这一段会检查长度是否大于包头长度。由下面这段调用。
// Unmarshal ...
func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error {
codec := hessian.NewHessianCodec(bufio.NewReaderSize(buf, buf.Len()))
// read header
err := codec.ReadHeader(&p.Header)
但是在bufio.NewReaderSize(buf, buf.Len())中
func NewReaderSize(rd io.Reader, size int) *Reader {
// Is it already a Reader?
b, ok := rd.(*Reader)
if ok && len(b.buf) >= size {
return b
}
if size < minReadBufferSize {
size = minReadBufferSize
}
r := new(Reader)
r.reset(make([]byte, size), rd)
return r
}
这里创建出的reader长度永远大于16.导致包头分包时,解包异常。
[ Full content available at: https://github.com/apache/dubbo-go/issues/380 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks closed issue #380: Bug: HessianCodec
failed to check package header length
Posted by "AlexStocks (GitHub)" <gi...@apache.org>.
[ issue closed by AlexStocks ]
[ Full content available at: https://github.com/apache/dubbo-go/issues/380 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo-go] witkeysa commented on issue #380: HessianCodec包头长度检查异常
Posted by "witkeysa (GitHub)" <gi...@apache.org>.
> @witkeysa maybe u should submit this issue to [dubbo-go-hessian2](github.com/apache/dubbo-go-hessian2)?
ok,thanks
[ Full content available at: https://github.com/apache/dubbo-go/issues/380 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo-go] witkeysa closed issue #380: HessianCodec包头长度检查异常
Posted by "witkeysa (GitHub)" <gi...@apache.org>.
[ issue closed by witkeysa ]
[ Full content available at: https://github.com/apache/dubbo-go/issues/380 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks commented on issue #380: HessianCodec包头长度检查异常
Posted by "AlexStocks (GitHub)" <gi...@apache.org>.
@witkeysa I have fix this issue in https://github.com/apache/dubbo-go/pull/381 and this pr will be merged into develop branch later. pls check this branch and make sure this bug is fixed. If not, pls tell me again here.
[ Full content available at: https://github.com/apache/dubbo-go/issues/380 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org