Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 May 2001 21:31:37 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        audit@FreeBSD.org
Cc:        green@FreeBSD.org
Subject:   dd BDECFLAGS cleanup
Message-ID:  <20010519213137.A13195@xor.obsecurity.org>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Please review the following.  Passes BDECFLAGS on the alpha and i386.

Kris

Index: Makefile
===================================================================
RCS file: /home/ncvs/src/bin/dd/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- Makefile	1999/12/07 03:32:37	1.8
+++ Makefile	2001/05/20 03:27:19
@@ -6,4 +6,6 @@
 
 MAINTAINER=	green@FreeBSD.org
 
+WARNS=	2
+
 .include <bsd.prog.mk>
Index: args.c
===================================================================
RCS file: /home/ncvs/src/bin/dd/args.c,v
retrieving revision 1.27
diff -u -r1.27 args.c
--- args.c	2000/10/22 23:00:32	1.27
+++ args.c	2001/05/20 04:22:30
@@ -168,8 +168,8 @@
 	/*
 	 * Bail out if the calculation of a file offset would overflow.
 	 */
-	if (in.offset > QUAD_MAX / in.dbsz || out.offset > QUAD_MAX / out.dbsz)
-		errx(1, "seek offsets cannot be larger than %qd", QUAD_MAX);
+	if ((unsigned long long)in.offset > QUAD_MAX / in.dbsz || (unsigned long long)out.offset > QUAD_MAX / out.dbsz)
+		errx(1, "seek offsets cannot be larger than %lld", (long long)QUAD_MAX);
 }
 
 static int
@@ -189,7 +189,7 @@
 
 	res = get_num(arg);
 	if (res < 1 || res > SSIZE_MAX)
-		errx(1, "bs must be between 1 and %d", SSIZE_MAX);
+		errx(1, "bs must be between 1 and %ld", (long)SSIZE_MAX);
 	in.dbsz = out.dbsz = (size_t)res;
 }
 
@@ -201,7 +201,7 @@
 
 	res = get_num(arg);
 	if (res < 1 || res > SSIZE_MAX)
-		errx(1, "cbs must be between 1 and %d", SSIZE_MAX);
+		errx(1, "cbs must be between 1 and %ld", (long)SSIZE_MAX);
 	cbsz = (size_t)res;
 }
 
@@ -224,7 +224,7 @@
 
 	files_cnt = get_num(arg);
 	if (files_cnt < 1)
-		errx(1, "files must be between 1 and %qd", QUAD_MAX);
+		errx(1, "files must be between 1 and %lld", (long long)QUAD_MAX);
 }
 
 static void
@@ -236,7 +236,7 @@
 	if (!(ddflags & C_BS)) {
 		res = get_num(arg);
 		if (res < 1 || res > SSIZE_MAX)
-			errx(1, "ibs must be between 1 and %d", SSIZE_MAX);
+			errx(1, "ibs must be between 1 and %ld", (long)SSIZE_MAX);
 		in.dbsz = (size_t)res;
 	}
 }
@@ -258,7 +258,7 @@
 	if (!(ddflags & C_BS)) {
 		res = get_num(arg);
 		if (res < 1 || res > SSIZE_MAX)
-			errx(1, "obs must be between 1 and %d", SSIZE_MAX);
+			errx(1, "obs must be between 1 and %ld", (long)SSIZE_MAX);
 		out.dbsz = (size_t)res;
 	}
 }
Index: dd.c
===================================================================
RCS file: /home/ncvs/src/bin/dd/dd.c,v
retrieving revision 1.31
diff -u -r1.31 dd.c
--- dd.c	2000/10/10 01:48:22	1.31
+++ dd.c	2001/05/20 04:24:47
@@ -71,8 +71,8 @@
 
 static void dd_close __P((void));
 static void dd_in __P((void));
-int main __P((int, char *[]));
 static void getfdtype __P((IO *));
+int main __P((int, char *[]));
 static void setup __P((void));
 
 IO	in, out;		/* input/output state */
@@ -87,9 +87,10 @@
 
 int
 main(argc, argv)
-	int argc;
+	int argc __unused;
 	char *argv[];
 {
+
 	(void)setlocale(LC_CTYPE, "");
 	jcl(argv);
 	setup();
@@ -175,7 +176,7 @@
 	 */
 	if ((ddflags & (C_OF | C_SEEK | C_NOTRUNC)) == (C_OF | C_SEEK) &&
 	    out.flags & ISTRUNC)
-		if (ftruncate(out.fd, out.offset * out.dbsz) == -1)
+		if (ftruncate(out.fd, out.offset * (off_t)out.dbsz) == -1)
 			err(1, "truncating %s", out.name);
 
 	/*
@@ -422,7 +423,7 @@
 						err(2, "%s: seek error creating sparse file",
 						    out.name);
 					if (force)
-						write(out.fd, outp, 1);
+						write(out.fd, outp, (size_t)1);
 					pending = 0;
 				}
 				if (cnt)
Index: misc.c
===================================================================
RCS file: /home/ncvs/src/bin/dd/misc.c,v
retrieving revision 1.18
diff -u -r1.18 misc.c
--- misc.c	1999/08/27 23:14:04	1.18
+++ misc.c	2001/05/20 04:27:36
@@ -48,6 +48,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 
 #include "dd.h"
@@ -66,29 +67,32 @@
 		secs = 1e-6;
 	/* Use snprintf(3) so that we don't reenter stdio(3). */
 	(void)snprintf(buf, sizeof(buf),
-	    "%qu+%qu records in\n%qu+%qu records out\n",
-	    st.in_full, st.in_part, st.out_full, st.out_part);
+	    "%llu+%llu records in\n%llu+%llu records out\n",
+	    (unsigned long long)st.in_full, (unsigned long long)st.in_part,
+	    (unsigned long long)st.out_full, (unsigned long long)st.out_part);
 	(void)write(STDERR_FILENO, buf, strlen(buf));
 	if (st.swab) {
-		(void)snprintf(buf, sizeof(buf), "%qu odd length swab %s\n",
-		     st.swab, (st.swab == 1) ? "block" : "blocks");
+		(void)snprintf(buf, sizeof(buf), "%llu odd length swab %s\n",
+		    (unsigned long long)st.swab,
+		    (st.swab == 1) ? "block" : "blocks");
 		(void)write(STDERR_FILENO, buf, strlen(buf));
 	}
 	if (st.trunc) {
-		(void)snprintf(buf, sizeof(buf), "%qu truncated %s\n",
-		     st.trunc, (st.trunc == 1) ? "block" : "blocks");
+		(void)snprintf(buf, sizeof(buf), "%llu truncated %s\n",
+		    (unsigned long long)st.trunc,
+		    (st.trunc == 1) ? "block" : "blocks");
 		(void)write(STDERR_FILENO, buf, strlen(buf));
 	}
 	(void)snprintf(buf, sizeof(buf),
-	    "%qu bytes transferred in %.6f secs (%.0f bytes/sec)\n",
-	    st.bytes, secs, st.bytes / secs);
+	    "%llu bytes transferred in %.6f secs (%.0f bytes/sec)\n",
+	    (unsigned long long)st.bytes, secs, st.bytes / secs);
 	(void)write(STDERR_FILENO, buf, strlen(buf));
 }
 
 /* ARGSUSED */
 void
 summaryx(notused)
-	int notused;
+	int notused __unused;
 {
 	int save_errno = errno;
 
Index: position.c
===================================================================
RCS file: /home/ncvs/src/bin/dd/position.c,v
retrieving revision 1.19
diff -u -r1.19 position.c
--- position.c	2000/10/22 23:00:32	1.19
+++ position.c	2001/05/20 04:28:25
@@ -70,7 +70,7 @@
 	/* If known to be seekable, try to seek on it. */
 	if (in.flags & ISSEEK) {
 		errno = 0;
-		if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 &&
+		if (lseek(in.fd, in.offset * (off_t)in.dbsz, SEEK_CUR) == -1 &&
 		    errno != 0)
 			err(1, "%s", in.name);
 		return;
@@ -136,7 +136,7 @@
 	 */
 	if (out.flags & (ISSEEK | ISPIPE)) {
 		errno = 0;
-		if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) == -1 &&
+		if (lseek(out.fd, out.offset * (off_t)out.dbsz, SEEK_CUR) == -1 &&
 		    errno != 0)
 			err(1, "%s", out.name);
 		return;

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7B0ioWry0BWjoQKURAu92AJ9GtFyVMNAH2kX3uzfPZhvd8FBU8wCggosi
+rgaBygXtlGcaj7Rt8kPDsQ=
=g72N
-----END PGP SIGNATURE-----

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