mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-03-10 11:10:23 +08:00
space monkey internal commit export
[katamari commit: ce73f75cb74ddc288a859ad3413c9a1a15380763]
This commit is contained in:
parent
f3fa51fc61
commit
e216ea8e48
6
bio.go
6
bio.go
@ -249,12 +249,18 @@ func (b *readBio) ReadFromOnce(r io.Reader) (n int, err error) {
|
|||||||
b.buf = new_buf
|
b.buf = new_buf
|
||||||
}
|
}
|
||||||
dst := b.buf[len(b.buf):cap(b.buf)]
|
dst := b.buf[len(b.buf):cap(b.buf)]
|
||||||
|
dst_slice := b.buf
|
||||||
b.data_mtx.Unlock()
|
b.data_mtx.Unlock()
|
||||||
|
|
||||||
n, err = r.Read(dst)
|
n, err = r.Read(dst)
|
||||||
b.data_mtx.Lock()
|
b.data_mtx.Lock()
|
||||||
defer b.data_mtx.Unlock()
|
defer b.data_mtx.Unlock()
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
|
if len(dst_slice) != len(b.buf) {
|
||||||
|
// someone shrunk the buffer, so we read in to far ahead and we
|
||||||
|
// need to slide backwards
|
||||||
|
copy(b.buf[len(b.buf):len(b.buf)+n], dst)
|
||||||
|
}
|
||||||
b.buf = b.buf[:len(b.buf)+n]
|
b.buf = b.buf[:len(b.buf)+n]
|
||||||
}
|
}
|
||||||
return n, err
|
return n, err
|
||||||
|
4
ctx.go
4
ctx.go
@ -136,7 +136,9 @@ func (c *Ctx) SetSessionId(session_id []byte) error {
|
|||||||
func (c *Ctx) SetCipherList(list string) error {
|
func (c *Ctx) SetCipherList(list string) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
if int(C.SSL_CTX_set_cipher_list(c.ctx, C.CString(list))) == 0 {
|
clist := C.CString(list)
|
||||||
|
defer C.free(unsafe.Pointer(clist))
|
||||||
|
if int(C.SSL_CTX_set_cipher_list(c.ctx, clist)) == 0 {
|
||||||
return errorFromErrorQueue()
|
return errorFromErrorQueue()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user