]> git.ipfire.org Git - thirdparty/qemu.git/commit
vnc: avoid underflow when accessing user-provided address
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 30 Mar 2023 12:23:40 +0000 (14:23 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 26 Apr 2023 15:17:51 +0000 (18:17 +0300)
commit6f7b9f7b6fdf8486e2f17fe3ddaeafe598c3b3a6
tree4490e9923fceae0e1e094b98ae8e5f25cd09d866
parentc1eb2ddf0f8075faddc5f7c3d39feae3e8e9d6b4
vnc: avoid underflow when accessing user-provided address

If hostlen is zero, there is a possibility that addrstr[hostlen - 1]
underflows and, if a closing bracked is there, hostlen - 2 is passed
to g_strndup() on the next line.  If websocket==false then
addrstr[0] would be a colon, but if websocket==true this could in
principle happen.

Fix it by checking hostlen.

Reported by Coverity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 3f9c41c5df9617510d8533cf6588172efb3df34b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
ui/vnc.c