Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 May 2016 19:10:29 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300322 - head/bin/ed
Message-ID:  <201605201910.u4KJAT13015624@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Fri May 20 19:10:29 2016
New Revision: 300322
URL: https://svnweb.freebsd.org/changeset/base/300322

Log:
  ed(1): Cleanups for the DES mode.
  
  - Use arc4random_uniform(3).
  - Prevent a segmentation fault when ed receives a signal
    while being in getpass(). [1]
  
  Obtained from:	OpenBSD [1] (CVS Rev. 1.15)
  MFC after:	2 weeks

Modified:
  head/bin/ed/cbc.c

Modified: head/bin/ed/cbc.c
==============================================================================
--- head/bin/ed/cbc.c	Fri May 20 19:05:33 2016	(r300321)
+++ head/bin/ed/cbc.c	Fri May 20 19:10:29 2016	(r300322)
@@ -99,7 +99,7 @@ init_des_cipher(void)
 
 	/* initialize the padding vector */
 	for (i = 0; i < 8; i++)
-		pvec[i] = (char) (arc4random() % 256);
+		pvec[i] = (char)arc4random_uniform(256);
 #endif
 }
 
@@ -164,7 +164,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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605201910.u4KJAT13015624>