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

--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Please review the following.  Passes BDECFLAGS on the alpha and i386.

Kris

Index: Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
=20
 MAINTAINER=3D	green@FreeBSD.org
=20
+WARNS=3D	2
+
 .include <bsd.prog.mk>
Index: args.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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);
 }
=20
 static int
@@ -189,7 +189,7 @@
=20
 	res =3D 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 =3D out.dbsz =3D (size_t)res;
 }
=20
@@ -201,7 +201,7 @@
=20
 	res =3D 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 =3D (size_t)res;
 }
=20
@@ -224,7 +224,7 @@
=20
 	files_cnt =3D 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);
 }
=20
 static void
@@ -236,7 +236,7 @@
 	if (!(ddflags & C_BS)) {
 		res =3D 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 =3D (size_t)res;
 	}
 }
@@ -258,7 +258,7 @@
 	if (!(ddflags & C_BS)) {
 		res =3D 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 =3D (size_t)res;
 	}
 }
Index: dd.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
=20
 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));
=20
 IO	in, out;		/* input/output state */
@@ -87,9 +87,10 @@
=20
 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)) =3D=3D (C_OF | C_SEEK) &&
 	    out.flags & ISTRUNC)
-		if (ftruncate(out.fd, out.offset * out.dbsz) =3D=3D -1)
+		if (ftruncate(out.fd, out.offset * (off_t)out.dbsz) =3D=3D -1)
 			err(1, "truncating %s", out.name);
=20
 	/*
@@ -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 =3D 0;
 				}
 				if (cnt)
Index: misc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
=20
 #include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
=20
 #include "dd.h"
@@ -66,29 +67,32 @@
 		secs =3D 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 =3D=3D 1) ? "block" : "blocks");
+		(void)snprintf(buf, sizeof(buf), "%llu odd length swab %s\n",
+		    (unsigned long long)st.swab,
+		    (st.swab =3D=3D 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 =3D=3D 1) ? "block" : "blocks");
+		(void)snprintf(buf, sizeof(buf), "%llu truncated %s\n",
+		    (unsigned long long)st.trunc,
+		    (st.trunc =3D=3D 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));
 }
=20
 /* ARGSUSED */
 void
 summaryx(notused)
-	int notused;
+	int notused __unused;
 {
 	int save_errno =3D errno;
=20
Index: position.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D 0;
-		if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) =3D=3D -1 &&
+		if (lseek(in.fd, in.offset * (off_t)in.dbsz, SEEK_CUR) =3D=3D -1 &&
 		    errno !=3D 0)
 			err(1, "%s", in.name);
 		return;
@@ -136,7 +136,7 @@
 	 */
 	if (out.flags & (ISSEEK | ISPIPE)) {
 		errno =3D 0;
-		if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) =3D=3D -1 &&
+		if (lseek(out.fd, out.offset * (off_t)out.dbsz, SEEK_CUR) =3D=3D -1 &&
 		    errno !=3D 0)
 			err(1, "%s", out.name);
 		return;

--yrj/dFKFPuw6o+aM
Content-Type: application/pgp-signature
Content-Disposition: inline

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

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

--yrj/dFKFPuw6o+aM--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




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