35633d45672d14bd798c478c45d1a17064701aa9 — Tobias Stoeckmann 5 years ago 2d2a21a
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[0] by pressing backspace with the current code.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
1 files changed, 1 insertions(+), 1 deletions(-)

M slock.c
M slock.c => slock.c +1 -1
@@ 177,7 177,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
			case XK_BackSpace:
				if (len)
					passwd[len--] = '\0';
					passwd[--len] = '\0';
				if (num && !iscntrl((int)buf[0]) &&