CVS commit: src/usr.bin/bdes

2016-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb  1 17:41:37 UTC 2016

Modified Files:
src/usr.bin/bdes: bdes.c

Log Message:
PR/50739: David Binderman: Check bounds before dereferencing.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/bdes/bdes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/bdes/bdes.c
diff -u src/usr.bin/bdes/bdes.c:1.9 src/usr.bin/bdes/bdes.c:1.10
--- src/usr.bin/bdes/bdes.c:1.9	Thu Aug 15 16:48:56 2013
+++ src/usr.bin/bdes/bdes.c	Mon Feb  1 12:41:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $	*/
+/*	$NetBSD: bdes.c,v 1.10 2016/02/01 17:41:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)bdes.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $");
+__RCSID("$NetBSD: bdes.c,v 1.10 2016/02/01 17:41:37 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -425,7 +425,7 @@ cvtkey(char *obuf, char *ibuf)
 			/*
 			 * now translate it, bombing on any illegal hex digit
 			 */
-			for (i = 0; ibuf[i] && i < 16; i++)
+			for (i = 0; i < 16 && ibuf[i]; i++)
 if ((nbuf[i] = tobinhex(ibuf[i], 16)) == -1)
 	bdes_err(-1, "bad hex digit in key");
 			while (i < 16)



CVS commit: src/usr.bin/bdes

2013-08-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Aug 15 20:48:56 UTC 2013

Modified Files:
src/usr.bin/bdes: bdes.c

Log Message:
Use more static and __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/bdes/bdes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/bdes/bdes.c
diff -u src/usr.bin/bdes/bdes.c:1.8 src/usr.bin/bdes/bdes.c:1.9
--- src/usr.bin/bdes/bdes.c:1.8	Tue Apr 14 10:11:28 2009
+++ src/usr.bin/bdes/bdes.c	Thu Aug 15 20:48:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $	*/
+/*	$NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)bdes.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $");
+__RCSID("$NetBSD: bdes.c,v 1.9 2013/08/15 20:48:56 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -141,44 +141,46 @@ typedef char Desbuf[8];
  */
 #define KEY_DEFAULT		0	/* interpret radix of key from key */
 #define KEY_ASCII		1	/* key is in ASCII characters */
-int keybase = KEY_DEFAULT;		/* how to interpret the key */
+static int keybase = KEY_DEFAULT;	/* how to interpret the key */
 
-enum { 	/* encrypt, decrypt, authenticate */
+static enum { /* encrypt, decrypt, authenticate */
 	MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE
 } mode = MODE_ENCRYPT;
-enum {	/* ecb, cbc, cfb, cfba, ofb? */
+static enum {/* ecb, cbc, cfb, cfba, ofb? */
 	ALG_ECB, ALG_CBC, ALG_CFB, ALG_OFB, ALG_CFBA
 } alg = ALG_CBC;
 
-Desbuf ivec;/* initialization vector */
-char bits[] = {/* used to extract bits from a char */
+static Desbuf ivec;/* initialization vector */
+static const char bits[] = {/* used to extract bits from a char */
 	'\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001'
 };
-int inverse;/* 0 to encrypt, 1 to decrypt */
-int macbits = -1;			/* number of bits in authentication */
-int fbbits = -1;			/* number of feedback bits */
-int pflag;/* 1 to preserve parity bits */
-
-int	setbits(char *, int);
-void	bdes_err(int, const char *);
-int	tobinhex(char, int);
-void	cvtkey(char *, char *);
-void	makekey(Desbuf);
-void	ecbenc(void);
-void	ecbdec(void);
-void	cbcenc(void);
-void	cbcdec(void);
-void	cbcauth(void);
-void	cfbenc(void);
-void	cfbdec(void);
-void	cfbaenc(void);
-void	cfbadec(void);
-void	ofbenc(void);
-void	ofbdec(void);
-void	cfbauth(void);
-void	expand(Desbuf, char *);
-void	compress(char *, Desbuf);
-void	usage(void);
+static int inverse;/* 0 to encrypt, 1 to decrypt */
+static int macbits = -1;			/* number of bits in authentication */
+static int fbbits = -1;			/* number of feedback bits */
+static int pflag;/* 1 to preserve parity bits */
+
+static int	setbits(char *, int);
+static void	bdes_err(int, const char *) __dead;
+static int	tobinhex(char, int);
+static void	cvtkey(char *, char *);
+static void	makekey(Desbuf);
+static void	ecbenc(void);
+static void	ecbdec(void);
+static void	cbcenc(void);
+static void	cbcdec(void);
+static void	cbcauth(void);
+static void	cfbenc(void);
+static void	cfbdec(void);
+static void	cfbaenc(void);
+static void	cfbadec(void);
+static void	ofbenc(void);
+static void	ofbdec(void);
+static void	cfbauth(void);
+#ifndef FASTWAY
+static void	expand(Desbuf, char *);
+static void	compress(char *, Desbuf);
+#endif
+static void	usage(void) __dead;
 
 int
 main(int ac, char *av[])
@@ -357,7 +359,7 @@ main(int ac, char *av[])
 /*
  * print a warning message and, possibly, terminate
  */
-void
+static void
 bdes_err(int n, const char *s)
 {
 	if (n > 0)
@@ -371,7 +373,7 @@ bdes_err(int n, const char *s)
 /*
  * map a hex character to an integer
  */
-int
+static int
 tobinhex(char c, int radix)
 {
 	switch(c) {
@@ -401,7 +403,7 @@ tobinhex(char c, int radix)
 /*
  * convert the key to a bit pattern
  */
-void
+static void
 cvtkey(char *obuf, char *ibuf)
 {
 	register int i, j;		/* counter in a for loop */
@@ -468,7 +470,7 @@ cvtkey(char *obuf, char *ibuf)
  * 2. must be a valid decimal number
  * 3. must be a multiple of mult
  */
-int
+static int
 setbits(char *s, int mult)
 {
 	char *p;
@@ -497,7 +499,7 @@ setbits(char *s, int mult)
  * systems set the parity (high) bit of each character to 0, and the
  * DES ignores the low order bit of each character.
  */
-void
+static void
 makekey(Desbuf buf)
 {
 	register int i, j;			/* counter in a for loop */
@@ -525,7 +527,7 @@ makekey(Desbuf buf)
 /*
  * This encrypts using the Electronic Code Book mode of DES
  */
-void
+static void
 ecbenc(void)
 {
 	register int n;		/* number of bytes actually read */
@@ -554,7 +556,7 @@ ecbenc(void)
 /*
  * This decrypts using the Electronic Code Book mode of DES
  */
-void
+static void
 ecbdec(void)
 {
 	register int n;		/* number of bytes actually read */
@@ -587,7 +589,7 @@

CVS commit: src/usr.bin/bdes

2013-08-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 11 06:47:38 UTC 2013

Modified Files:
src/usr.bin/bdes: Makefile

Log Message:
Passes WARNS=5, so don't set WARNS=3.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/bdes/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/bdes/Makefile
diff -u src/usr.bin/bdes/Makefile:1.7 src/usr.bin/bdes/Makefile:1.8
--- src/usr.bin/bdes/Makefile:1.7	Mon May 28 12:06:24 2007
+++ src/usr.bin/bdes/Makefile	Sun Aug 11 06:47:38 2013
@@ -1,9 +1,8 @@
-#	$NetBSD: Makefile,v 1.7 2007/05/28 12:06:24 tls Exp $
+#	$NetBSD: Makefile,v 1.8 2013/08/11 06:47:38 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 USE_FORT?=	yes	# cryptographic software
 
-WARNS=	3
 PROG=	bdes
 
 LDADD+=	-lcrypt



CVS commit: src/usr.bin/bdes

2010-01-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jan 15 19:40:18 UTC 2010

Modified Files:
src/usr.bin/bdes: bdes.1

Log Message:
Use .%U instead of .%O for URLs.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/bdes/bdes.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/bdes/bdes.1
diff -u src/usr.bin/bdes/bdes.1:1.13 src/usr.bin/bdes/bdes.1:1.14
--- src/usr.bin/bdes/bdes.1:1.13	Fri Jun  4 10:28:37 2004
+++ src/usr.bin/bdes/bdes.1	Fri Jan 15 19:40:17 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bdes.1,v 1.13 2004/06/04 10:28:37 wiz Exp $
+.\"	$NetBSD: bdes.1,v 1.14 2010/01/15 19:40:17 joerg Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -312,7 +312,7 @@
 .%A Wiener
 .%T Minimal Key Lengths for Symmetric Ciphers To Provide Adequate Commercial Security
 .%I Business Software Alliance
-.%O http://www.bsa.org/policy/encryption/cryptographers.html
+.%U http://www.bsa.org/policy/encryption/cryptographers.html
 .%D January 1996
 .Re
 .Sh BUGS



CVS commit: src/usr.bin/bdes

2009-04-14 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue Apr 14 10:11:28 UTC 2009

Modified Files:
src/usr.bin/bdes: bdes.c

Log Message:
Fix sign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/bdes/bdes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/bdes/bdes.c
diff -u src/usr.bin/bdes/bdes.c:1.7 src/usr.bin/bdes/bdes.c:1.8
--- src/usr.bin/bdes/bdes.c:1.7	Mon Jul 21 14:19:21 2008
+++ src/usr.bin/bdes/bdes.c	Tue Apr 14 10:11:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdes.c,v 1.7 2008/07/21 14:19:21 lukem Exp $	*/
+/*	$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)bdes.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: bdes.c,v 1.7 2008/07/21 14:19:21 lukem Exp $");
+__RCSID("$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,7 @@
  */
 #define	READ(buf, n)	fread(buf, sizeof(char), n, stdin)
 #define WRITE(buf,n)		\
-		if (fwrite(buf, sizeof(char), n, stdout) != n)	\
+		if (fwrite(buf, sizeof(char), n, stdout) != (size_t)n)	\
 			bdes_err(bn, NULL);
 
 /*