From edddd69f17803d29b7f435da85ef23b7a5430c1f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 16 May 2013 14:09:08 +0800 Subject: [PATCH] Usermode/libposix - Fixed bug in getpass (didn't trim \n) --- Usermode/Libraries/libposix.so_src/fcntl.c | 2 +- Usermode/Libraries/libposix.so_src/unistd.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Usermode/Libraries/libposix.so_src/fcntl.c b/Usermode/Libraries/libposix.so_src/fcntl.c index 76d6f6be..431c2cbb 100644 --- a/Usermode/Libraries/libposix.so_src/fcntl.c +++ b/Usermode/Libraries/libposix.so_src/fcntl.c @@ -43,8 +43,8 @@ int fcntl(int fd, int cmd, ...) a_flags |= OPENFLAG_APPEND; // TODO: Extra flags for F_SETFL - _SysDebug("fcntl(%i, F_SETFL, %i)", fd, p_flags); ret = _SysFDFlags(fd, mask, a_flags); + _SysDebug("fcntl(%i, F_SETFL, %li) = %i", fd, p_flags, ret); if(ret != -1) ret = 0; diff --git a/Usermode/Libraries/libposix.so_src/unistd.c b/Usermode/Libraries/libposix.so_src/unistd.c index 2d0a7e4a..78896db9 100644 --- a/Usermode/Libraries/libposix.so_src/unistd.c +++ b/Usermode/Libraries/libposix.so_src/unistd.c @@ -10,6 +10,7 @@ #include #include #include +#include // === CODE === int unlink(const char *pathname) @@ -182,6 +183,8 @@ char *getpass(const char *prompt) fprintf(stderr, "%s", prompt); fgets(passbuf, PASS_MAX+1, stdin); fprintf(stderr, "\n"); + for( int i = strlen(passbuf); i > 0 && (passbuf[i-1] == '\r' || passbuf[i-1] == '\n'); i -- ) + passbuf[i-1] = 0; return passbuf; } -- 2.20.1