diff options
author | Enrico Scholz <enrico.scholz@sigma-chemnitz.de> | 2012-12-04 13:04:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-12-05 10:38:27 +0100 |
commit | e7111ebd28a074a8f6bcb5c06e3a30816c0a0cd2 (patch) | |
tree | 6c977000d72814018250a72a4c5de3c734446fef /common/password.c | |
parent | 6f70eea9ca557fa4322b36d4d0dc21cd710737b9 (diff) | |
download | barebox-e7111ebd28a074a8f6bcb5c06e3a30816c0a0cd2.tar.gz barebox-e7111ebd28a074a8f6bcb5c06e3a30816c0a0cd2.tar.xz |
password: fixed underflow on <backspace>
due to missing/misplaced boundary check, deleting characters could
underflow the password buffer.
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/password.c')
-rw-r--r-- | common/password.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/common/password.c b/common/password.c index a03e1dbff7..d157a11b7b 100644 --- a/common/password.c +++ b/common/password.c @@ -66,11 +66,14 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout) case CTL_CH('h'): case KEY_DEL7: case KEY_DEL: - if (flags & STAR && pos > 0) - puts("\b \b"); - *buf = '\0'; - buf--; - pos--; + if (pos > 0) { + if (flags & STAR) + puts("\b \b"); + + *buf = '\0'; + buf--; + pos--; + } continue; default: if (pos < length - 1) { |