Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/dd Fix a very old bug. When allocating the buffer and d...
details: https://anonhg.NetBSD.org/src/rev/e5e481379b61
branches: trunk
changeset: 777498:e5e481379b61
user: matt <matt%NetBSD.org@localhost>
date: Tue Feb 21 01:49:01 2012 +0000
description:
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.
diffstat:
bin/dd/dd.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diffs (30 lines):
diff -r 7ee78056f804 -r e5e481379b61 bin/dd/dd.c
--- a/bin/dd/dd.c Tue Feb 21 01:47:50 2012 +0000
+++ b/bin/dd/dd.c Tue Feb 21 01:49:01 2012 +0000
@@ -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 @@
#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 @@
* 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 */
}
Home |
Main Index |
Thread Index |
Old Index