Usermode/libposix - Fixed bug in getpass (didn't trim \n)
authorJohn Hodge <[email protected]>
Thu, 16 May 2013 06:09:08 +0000 (14:09 +0800)
committerJohn Hodge <[email protected]>
Thu, 16 May 2013 06:09:08 +0000 (14:09 +0800)
Usermode/Libraries/libposix.so_src/fcntl.c
Usermode/Libraries/libposix.so_src/unistd.c

index 76d6f6b..431c2cb 100644 (file)
@@ -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;
 
index 2d0a7e4..78896db 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdarg.h>
 #include <sys/select.h>
 #include <stdio.h>
+#include <string.h>
 
 // === 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;
 }
 

UCC git Repository :: git.ucc.asn.au