* pem(8) fix
@ 2020-01-29 19:51 Demetrius Iatrakis
0 siblings, 0 replies; only message in thread
From: Demetrius Iatrakis @ 2020-01-29 19:51 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
pem(8) cannot read from stdin in case "#d/0" is not accessible. This
patch fixes this bug by removing the file argument, and only reading
from stdin instead.
[-- Attachment #2: pem.patch --]
[-- Type: application/octet-stream, Size: 2668 bytes --]
diff -r 1d345066125a sys/man/8/pem
--- a/sys/man/8/pem Fri Oct 04 18:54:01 2019 +0200
+++ b/sys/man/8/pem Wed Jan 29 21:48:11 2020 +0200
@@ -5,15 +5,9 @@
.PP
.B auth/pemdecode
.I section
-[
-.I file
-]
.PP
.B auth/pemencode
.I section
-[
-.I file
-]
.SH DESCRIPTION
PEM is a textual encoding for binary data originally used by the
Privacy Enhanced Mail program but now commonly used for
diff -r 1d345066125a sys/man/8/rsa
--- a/sys/man/8/rsa Fri Oct 04 18:54:01 2019 +0200
+++ b/sys/man/8/rsa Wed Jan 29 21:48:11 2020 +0200
@@ -270,7 +270,7 @@
and load it into factotum:
.IP
.EX
-auth/pemdecode 'PRIVATE KEY' key.pem |
+auth/pemdecode 'PRIVATE KEY' < key.pem |
auth/asn12rsa -t 'service=tls' >/mnt/factotum/ctl
.EE
.PP
diff -r 1d345066125a sys/src/cmd/auth/pemdecode.c
--- a/sys/src/cmd/auth/pemdecode.c Fri Oct 04 18:54:01 2019 +0200
+++ b/sys/src/cmd/auth/pemdecode.c Wed Jan 29 21:48:11 2020 +0200
@@ -5,7 +5,7 @@
void
usage(void)
{
- fprint(2, "auth/pemdecode section [file]\n");
+ fprint(2, "auth/pemdecode section\n");
exits("usage");
}
@@ -14,34 +14,26 @@
{
char *buf;
uchar *bin;
- int fd;
long n, tot;
int len;
- char *tag, *file;
+ char *tag;
ARGBEGIN{
default:
usage();
}ARGEND
- if(argc != 1 && argc != 2)
+ if(argc != 1)
usage();
tag = argv[0];
- if(argc == 2)
- file = argv[1];
- else
- file = "#d/0";
-
- if((fd = open(file, OREAD)) < 0)
- sysfatal("open %s: %r", file);
buf = nil;
tot = 0;
for(;;){
buf = realloc(buf, tot+8192);
if(buf == nil)
sysfatal("realloc: %r");
- if((n = read(fd, buf+tot, 8192)) < 0)
+ if((n = read(0, buf+tot, 8192)) < 0)
sysfatal("read: %r");
if(n == 0)
break;
diff -r 1d345066125a sys/src/cmd/auth/pemencode.c
--- a/sys/src/cmd/auth/pemencode.c Fri Oct 04 18:54:01 2019 +0200
+++ b/sys/src/cmd/auth/pemencode.c Wed Jan 29 21:48:11 2020 +0200
@@ -5,7 +5,7 @@
void
usage(void)
{
- fprint(2, "auth/pemencode section [file]\n");
+ fprint(2, "auth/pemencode section\n");
exits("usage");
}
@@ -13,34 +13,26 @@
main(int argc, char **argv)
{
char *buf, *cbuf;
- int fd;
long n, tot;
int len;
- char *tag, *file;
+ char *tag;
ARGBEGIN{
default:
usage();
}ARGEND
- if(argc != 1 && argc != 2)
+ if(argc != 1)
usage();
tag = argv[0];
- if(argc == 2)
- file = argv[1];
- else
- file = "#d/0";
-
- if((fd = open(file, OREAD)) < 0)
- sysfatal("open %s: %r", file);
buf = nil;
tot = 0;
for(;;){
buf = realloc(buf, tot+8192);
if(buf == nil)
sysfatal("realloc: %r");
- if((n = read(fd, buf+tot, 8192)) < 0)
+ if((n = read(0, buf+tot, 8192)) < 0)
sysfatal("read: %r");
if(n == 0)
break;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-01-29 19:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 19:51 pem(8) fix Demetrius Iatrakis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).