summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-06-03 03:20:54 +0000
committerpfg <pfg@FreeBSD.org>2016-06-03 03:20:54 +0000
commit84d7d3078285fa2f1456ebdf40ba393524b4c84f (patch)
tree85189cfb51ea782ee4f170d2a4291c2b66e24311 /bin
parent063e637ba96b3f9bb5c3cb8de7299e810fd95538 (diff)
downloadFreeBSD-src-84d7d3078285fa2f1456ebdf40ba393524b4c84f.zip
FreeBSD-src-84d7d3078285fa2f1456ebdf40ba393524b4c84f.tar.gz
MFC r300322, 300340:
ed(1): Cleanups for the DES mode. - Use arc4random_buf(3). - Prevent a segmentation fault when ed receives a signal while being in getpass(). [1] Obtained from: OpenBSD [1] (CVS Rev. 1.15)
Diffstat (limited to 'bin')
-rw-r--r--bin/ed/cbc.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/bin/ed/cbc.c b/bin/ed/cbc.c
index 3985721..b59778b 100644
--- a/bin/ed/cbc.c
+++ b/bin/ed/cbc.c
@@ -90,16 +90,13 @@ void
init_des_cipher(void)
{
#ifdef DES
- int i;
-
des_ct = des_n = 0;
/* initialize the initialization vector */
MEMZERO(ivec, 8);
/* initialize the padding vector */
- for (i = 0; i < 8; i++)
- pvec[i] = (char) (arc4random() % 256);
+ arc4random_buf(pvec, sizeof(pvec));
#endif
}
@@ -164,7 +161,7 @@ get_keyword(void)
/*
* get the key
*/
- if (*(p = getpass("Enter key: "))) {
+ if ((p = getpass("Enter key: ")) != NULL && *p != '\0') {
/*
* copy it, nul-padded, into the key area
OpenPOWER on IntegriCloud