summaryrefslogtreecommitdiffstats
path: root/bin/dd
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2000-10-22 23:00:32 +0000
committergreen <green@FreeBSD.org>2000-10-22 23:00:32 +0000
commitaa2e16431f81c11561492c59548f84873b57ae1e (patch)
tree7d146375703445b82bfd0df3d089f37cb9fb2e88 /bin/dd
parente3a7d71c8203c4a03e4a1346f836d97aaf6c0def (diff)
downloadFreeBSD-src-aa2e16431f81c11561492c59548f84873b57ae1e.zip
FreeBSD-src-aa2e16431f81c11561492c59548f84873b57ae1e.tar.gz
Allow negative seek offsets for files that can be seeked upon. It
makes dd(1) a more complete "filter", even if this functionality is limited to seekable streams.
Diffstat (limited to 'bin/dd')
-rw-r--r--bin/dd/args.c4
-rw-r--r--bin/dd/position.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/bin/dd/args.c b/bin/dd/args.c
index e118712..252f0fa 100644
--- a/bin/dd/args.c
+++ b/bin/dd/args.c
@@ -428,7 +428,7 @@ get_offset(val)
quad_t num;
num = get_num(val);
- if (num > QUAD_MAX || num < 0) /* XXX quad_t != off_t */
- errx(1, "%s: illegal offset", oper); /* Too big/negative. */
+ if (num > QUAD_MAX) /* XXX can't happen && quad_t != off_t */
+ errx(1, "%s: illegal offset", oper); /* Too big. */
return ((off_t)num);
}
diff --git a/bin/dd/position.c b/bin/dd/position.c
index 10020d0..1a9c4b1 100644
--- a/bin/dd/position.c
+++ b/bin/dd/position.c
@@ -76,6 +76,10 @@ pos_in()
return;
}
+ /* Don't try to read a really weird amount (like negative). */
+ if (in.offset < 0)
+ errx(1, "%s: illegal offset", "iseek/skip");
+
/*
* Read the data. If a pipe, read until satisfy the number of bytes
* being skipped. No differentiation for reading complete and partial
@@ -138,6 +142,10 @@ pos_out()
return;
}
+ /* Don't try to read a really weird amount (like negative). */
+ if (out.offset < 0)
+ errx(1, "%s: illegal offset", "oseek/seek");
+
/* If no read access, try using mtio. */
if (out.flags & NOREAD) {
t_op.mt_op = MTFSR;
OpenPOWER on IntegriCloud