benruijl / sflock

Simple X display locker, with basic user feedback. Based on slock.
MIT License
50 stars 21 forks source link

Special chars in passwords not working #15

Open c0d3z3r0 opened 8 years ago

c0d3z3r0 commented 8 years ago

When using special chars like § (in fact the only one I've tested) you cannot unlock the screen anymore

rschlossarek commented 6 years ago

I have the Same problem.. I am a german arch user and youse äöü in my passwd

ret2fail commented 2 years ago

Sorry for reviving this but I found a workaround and wanted to share it, in case someone is looking for sflock unicode or slock unicode in the future.

X11 doesn't handle unicode chars very well so what you can do is add more cases to the switch before the default like the following:

case XK_aacute:
    if(num && !iscntrl((int) buf[0]) && (len + 2 < sizeof passwd)) { 
        memcpy(passwd + len, "á", 2);
        len += 2;
    }
    break;

This results in an obvious attack where you can guess that the char "á" is part of the password, so for good measure try to implement this using all the characters of your language. You can get the codes and aliases for the XK_yoursymbol in keysymdef.h. The location of this file may vary but you can find it using:

find / -name keysymdef.h 2>/dev/null

This worked for me on slock and I am assuming that it works here too, although the number of * that appear when you type your password may vary, haven't checked how this change affects it