Fix buffer-overrun bug in net (#17728) [backport:1.0]
This commit is contained in:
parent
d19e4310dc
commit
fdd4391534
2 changed files with 5 additions and 4 deletions
|
|
@ -40,6 +40,8 @@
|
||||||
## Standard library additions and changes
|
## Standard library additions and changes
|
||||||
- Added support for parenthesized expressions in `strformat`
|
- Added support for parenthesized expressions in `strformat`
|
||||||
|
|
||||||
|
- Fixed buffer overflow bugs in `net`
|
||||||
|
|
||||||
- Added `sections` iterator in `parsecfg`.
|
- Added `sections` iterator in `parsecfg`.
|
||||||
|
|
||||||
- Make custom op in macros.quote work for all statements.
|
- Make custom op in macros.quote work for all statements.
|
||||||
|
|
|
||||||
|
|
@ -690,12 +690,11 @@ when defineSsl:
|
||||||
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
||||||
let hintString = if hint == nil: "" else: $hint
|
let hintString = if hint == nil: "" else: $hint
|
||||||
let (identityString, pskString) = (ctx.clientGetPskFunc)(hintString)
|
let (identityString, pskString) = (ctx.clientGetPskFunc)(hintString)
|
||||||
if psk.len.cuint > max_psk_len:
|
if pskString.len.cuint > max_psk_len:
|
||||||
return 0
|
return 0
|
||||||
if identityString.len.cuint >= max_identity_len:
|
if identityString.len.cuint >= max_identity_len:
|
||||||
return 0
|
return 0
|
||||||
|
copyMem(identity, identityString.cstring, identityString.len + 1) # with the last zero byte
|
||||||
copyMem(identity, identityString.cstring, pskString.len + 1) # with the last zero byte
|
|
||||||
copyMem(psk, pskString.cstring, pskString.len)
|
copyMem(psk, pskString.cstring, pskString.len)
|
||||||
|
|
||||||
return pskString.len.cuint
|
return pskString.len.cuint
|
||||||
|
|
@ -716,7 +715,7 @@ when defineSsl:
|
||||||
max_psk_len: cint): cuint {.cdecl.} =
|
max_psk_len: cint): cuint {.cdecl.} =
|
||||||
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
|
||||||
let pskString = (ctx.serverGetPskFunc)($identity)
|
let pskString = (ctx.serverGetPskFunc)($identity)
|
||||||
if psk.len.cint > max_psk_len:
|
if pskString.len.cint > max_psk_len:
|
||||||
return 0
|
return 0
|
||||||
copyMem(psk, pskString.cstring, pskString.len)
|
copyMem(psk, pskString.cstring, pskString.len)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue