From 81422098f57f568499de2fba55a606c74575aba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 31 Jan 2011 14:02:15 +0200 Subject: ximcp/imLckup: Handle negative return value from _Xlcwctomb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed by negative value to memcpy by checking for the negative return value of _Xlcwctomb and returning 0/XLookupNone in that case. a negative value was passed to memcpy Unfortunately the other return values for *status don't fit into the error (which appears to indicate some internal error or running out of memory). The other valid status codes are XBufferOverflow, XLookupNone, XLookupChars, XLookupKeySym, and XLookupBoth. Each of these has a specific meaning attached. Reviewed-by: Ander Conselvan de Oliveira Signed-off-by: Erkki Seppälä Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imLcLkup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c index 9449b9f43..f2f96e280 100644 --- a/nx-X11/lib/X11/imLcLkup.c +++ b/nx-X11/lib/X11/imLcLkup.c @@ -63,6 +63,10 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes, unsigned char pattern = ic->private.local.brl_committed; char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)]; ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern); + if(ret < 0) { + if(status) *status = XLookupNone; + return(0); + } if(ret > bytes) { if(status) *status = XBufferOverflow; return(ret); -- cgit v1.2.3