Author: Tobias Stoeckmann <firstname.lastname@example.org>
Date: Sat, 25 Mar 2017 21:16:01 +0100
Properly clear the last entered character
When enter is pressed, passwd[len] will be set to '\0'. Pressing
backspace is supposed to remove the last entered character.
But currently, the clearing has an off-by-one, as in setting
passwd[len] to '\0' just like enter would do.
You can also verify it by imagining len=1 and that it's impossible to
clear passwd by pressing backspace with the current code.
Signed-off-by: Tobias Stoeckmann <email@example.com>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/slock.c b/slock.c
@@ -177,7 +177,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
- passwd[len--] = '\0';
+ passwd[--len] = '\0';
if (num && !iscntrl((int)buf) &&