Commit 9f59ab99 authored by ceddral's avatar ceddral
Browse files

telnet_gui/screen: fix screen size TOCTOU

bounds check must be done inside the lock.. duh
parent 65e9c092
......@@ -220,11 +220,11 @@ func NewView(s *Screen, x, y, w, h int) (v *View) {
}
func (v *View) DrawBlockRaw(block []byte, x, y int) {
v.S.mutex.Lock()
defer v.S.mutex.Unlock()
if x < 0 || y < 0 || v.W <= x || v.H <= y {
return
}
v.S.mutex.Lock()
defer v.S.mutex.Unlock()
v.S.drawBlockUnlockedRaw(block, v.X + x, v.Y + y)
}
......@@ -233,11 +233,11 @@ func (v *View) DrawBlock(fg, bg Color, symbol byte, x, y int) {
}
func (v *View) DrawBlockAttr(fg, bg Color, symbol byte, x, y int, underline, bold Attr) {
v.S.mutex.Lock()
defer v.S.mutex.Unlock()
if x < 0 || y < 0 || v.W <= x || v.H <= y {
return
}
v.S.mutex.Lock()
defer v.S.mutex.Unlock()
v.S.drawBlockUnlocked(fg, bg, symbol, v.X+x, v.Y+y, underline, bold)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment