wm: teppich

Download patch

ref: e59fdba360cf7884bcb964b4ee999fcf8aaad16a
parent: 8fe978f00633ce7bdf4c0413e72b5a78ddca7bec
author: mkf <mkf@cloud9p.org>
date: Sun Dec 3 15:44:01 EST 2023

login: don't print characters, fix some oveflow issues as well

--- a/cmd/login.c
+++ b/cmd/login.c
@@ -76,12 +76,20 @@
 	i = 0;
 	p = malloc(PASSWD_MAX);
 	
-	while(i < PASSWD_MAX - 1)
+	while(1)
 	{
+		
 		c = ps2_getc();
 		
-		if(c == '\b')
+		if(c == '\r')
 		{
+			p[i] = '\0';
+			break;
+		}
+		else if(i >= PASSWD_MAX - 1) /* silently ignore */
+			continue;
+		else if(c == '\b')
+		{
 			if(i)
 				i--;
 			p[i] = '\0';
@@ -88,19 +96,14 @@
 			printf("\b");
 			continue;
 		}
-		else if(c == '\r')
-		{
-			p[i] = '\0';
-			break;
-		}
+
 		p[i] = c;
-		printf("*");
 		i++;
 	}
 	printf("\n");
 	
 
-	if(i > PASSWD_MAX)
+	if(i > PASSWD_MAX - 1)
 	{
 		printf("\noverflow!\n");
 		return OVERFLOW;
@@ -113,7 +116,8 @@
 	}
 	else
 	{
-		printf("%s", answers[(i) % (sizeof(answers) / sizeof(char*))]);
+		printf("%s", answers[i % (sizeof(answers) / sizeof(char*))]);
 		return AUTH_FAILED;
 	}
 }
+