svn commit: r301234 - stable/9/bin/ed

Pedro F. Giffuni pfg at FreeBSD.org
Fri Jun 3 03:22:02 UTC 2016


Author: pfg
Date: Fri Jun  3 03:22:00 2016
New Revision: 301234
URL: https://svnweb.freebsd.org/changeset/base/301234

Log:
  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)

Modified:
  stable/9/bin/ed/cbc.c
Directory Properties:
  stable/9/bin/ed/   (props changed)

Modified: stable/9/bin/ed/cbc.c
==============================================================================
--- stable/9/bin/ed/cbc.c	Fri Jun  3 03:20:54 2016	(r301233)
+++ stable/9/bin/ed/cbc.c	Fri Jun  3 03:22:00 2016	(r301234)
@@ -96,16 +96,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
 }
 
@@ -170,7 +167,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


More information about the svn-src-stable-9 mailing list