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.
This commit is contained in:
parent
b608e3ff66
commit
53885065b7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67451
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user