Module Name:    src
Committed By:   matt
Date:           Tue Feb 21 01:49:02 UTC 2012

Modified Files:
        src/bin/dd: dd.c

Log Message:
Fix a very old bug.  When allocating the buffer and doing just a bs= transfer,
hen we only need a single buffer equal to that blocksize in length.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/bin/dd/dd.c

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

Modified files:

Index: src/bin/dd/dd.c
diff -u src/bin/dd/dd.c:1.48 src/bin/dd/dd.c:1.49
--- src/bin/dd/dd.c:1.48	Sun Nov  6 21:22:23 2011
+++ src/bin/dd/dd.c	Tue Feb 21 01:49:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: dd.c,v 1.48 2011/11/06 21:22:23 jym Exp $	*/
+/*	$NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dd.c	8.5 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: dd.c,v 1.48 2011/11/06 21:22:23 jym Exp $");
+__RCSID("$NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -212,7 +212,10 @@ setup(void)
 	 * record oriented I/O, only need a single buffer.
 	 */
 	if (!(ddflags & (C_BLOCK|C_UNBLOCK))) {
-		if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) {
+		size_t dbsz = out.dbsz;
+		if (!(ddflags & C_BS))
+			dbsz += in.dbsz - 1;
+		if ((in.db = malloc(dbsz)) == NULL) {
 			err(EXIT_FAILURE, NULL);
 			/* NOTREACHED */
 		}

Reply via email to