[hackers] [dmenu] keypress, check if len > 0 just in case before reading buf || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 13 Sep 2026 20:53:39 +0200 (CEST)

commit 61e0072c3e6adfc67bafbc84e376cf26bc3680c0
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sun Sep 13 20:48:49 2026 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sun Sep 13 20:48:49 2026 +0200

    keypress, check if len > 0 just in case before reading buf
    
    I'm not sure if this can happen, but check it just in case:
    
    Maybe possible when:
    
    len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
    len == 0 and case XLookupChars would be executed on a keypress.
    
    Reported by: jb19357 <jb19357_AT_protonmail.com>
    Who used Claude to write a report.
    
    I cannot reproduce this issue, but it seems logical.

diff --git a/dmenu.c b/dmenu.c
index 11a0551..c2425e2 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -414,7 +414,7 @@ keypress(XKeyEvent *ev)
         switch(ksym) {
         default:
 insert:
- if (!iscntrl((unsigned char)*buf))
+ if (len > 0 && !iscntrl((unsigned char)*buf))
                         insert(buf, len);
                 break;
         case XK_Delete:
Received on Sun Sep 13 2026 - 20:53:39 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 13 2026 - 21:00:40 CEST