shithub: riscv

Download patch

ref: 8b72726549be9e816ca8af0b9489948cc4fccb41
parent: 8a903895a08c67fb4bb02fb21e2186a0e08b0513
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Feb 28 14:21:03 EST 2013

ape: add PASS_MAX constant for getpass() to limits.h (from patch/ape-pass_max)

add PASS_MAX to limits.h for ape, and make getpass respect it. also increase the size of
the maximum passwords (we use long ones at work). Needed for native port of SVN (in progress).

--- a/sys/include/ape/limits.h
+++ b/sys/include/ape/limits.h
@@ -65,6 +65,7 @@
 #define NGROUPS_MAX 10
 /*#define OPEN_MAX _POSIX_OPEN_MAX */
 /*#define PAGESIZE 1 */
+#define PASS_MAX 64
 /*#define PATH_MAX _POSIX_PATH_MAX */
 /*#define PIPE_BUF _POSIX_PIPE_BUF */
 /*#define RTSIG_MAX _POSIX_RTSIG_MAX */
--- a/sys/src/ape/lib/v/plan9/getpass.c
+++ b/sys/src/ape/lib/v/plan9/getpass.c
@@ -2,6 +2,7 @@
 #define _RESEARCH_SOURCE
 #include <stdio.h>
 #include <signal.h>
+#include <limits.h>
 #include <libv.h>
 
 char *
@@ -10,7 +11,7 @@
 	int c;
 	char *p;
 	FILE *fi;
-	static char pbuf[9];
+	static char pbuf[PASS_MAX];
 	void (*sig)(int);
 
 	if ((fi = fopen("/dev/cons", "r")) == NULL)
@@ -28,7 +29,7 @@
 		else if (c == '\b') {
 			if (p > pbuf)
 				p--;
-		} else if (p < &pbuf[8])
+		} else if (p < &pbuf[sizeof(pbuf)-1])
 			*p++ = c;
 	*p = '\0';
 
--