Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jun 2016 03:20:54 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r301233 - stable/10/bin/ed
Message-ID:  <201606030320.u533KsmR099859@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Fri Jun  3 03:20:54 2016
New Revision: 301233
URL: https://svnweb.freebsd.org/changeset/base/301233

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/10/bin/ed/cbc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/ed/cbc.c
==============================================================================
--- stable/10/bin/ed/cbc.c	Fri Jun  3 03:12:28 2016	(r301232)
+++ stable/10/bin/ed/cbc.c	Fri Jun  3 03:20:54 2016	(r301233)
@@ -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



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