From 856daf2443ee60f6b56e469e3a7f6600e599aaee Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Wed, 5 Aug 2015 13:25:22 +0100 Subject: Fix buffer overflow in xev.c If initially buffer is smaller size returned is too big, do not use to terminate the string. Signed-off-by: Frediano Ziglio --- xev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xev.c b/xev.c index 3146d81..6f6b5bb 100644 --- a/xev.c +++ b/xev.c @@ -101,13 +101,13 @@ do_KeyPress (XEvent *eventp) if (e->type == KeyPress && xic) { do { nmbbytes = XmbLookupString (xic, e, buf, bsize - 1, &ks, &status); - buf[nmbbytes] = '\0'; if (status == XBufferOverflow) { bsize = nmbbytes + 1; buf = realloc (buf, bsize); } } while (status == XBufferOverflow); + buf[nmbbytes] = '\0'; } if (ks == NoSymbol) -- cgit v1.2.3