diff options
author | pfg <pfg@FreeBSD.org> | 2016-06-03 03:20:54 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-06-03 03:20:54 +0000 |
commit | 84d7d3078285fa2f1456ebdf40ba393524b4c84f (patch) | |
tree | 85189cfb51ea782ee4f170d2a4291c2b66e24311 | |
parent | 063e637ba96b3f9bb5c3cb8de7299e810fd95538 (diff) | |
download | FreeBSD-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)
-rw-r--r-- | bin/ed/cbc.c | 7 |
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 |