提交 3ec8b3ae 编写于 作者: R Rich Felker

fix one-byte overflow in legacy getpass function

if the length of the input was equal to the buffer size (128), a fixed
value of zero was written one byte past the end of the static buffer.
上级 733d1ea7
...@@ -27,7 +27,7 @@ char *getpass(const char *prompt) ...@@ -27,7 +27,7 @@ char *getpass(const char *prompt)
l = read(fd, password, sizeof password); l = read(fd, password, sizeof password);
if (l >= 0) { if (l >= 0) {
if (l > 0 && password[l-1] == '\n') l--; if (l > 0 && password[l-1] == '\n' || l==sizeof password) l--;
password[l] = 0; password[l] = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册