diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-01-19 15:15:12 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-01-19 15:15:12 -0800 |
commit | cb7ba0e640f7226fedaecb6d1289bebabe033a3b (patch) | |
tree | a20ad5c7298fc4b03f8366b0a09ec72f2bec113e | |
parent | 67c15c1e4794103dc3eeb8d76ed0b5e39b321780 (diff) | |
download | plan9front-cb7ba0e640f7226fedaecb6d1289bebabe033a3b.tar.xz |
dd: error with invalid size suffixes, add 'm'
When invoking with dd with an invalid size suffix, we
silently accept the suffix. This can lead to confusion,
because lines like:
dd -bs 1K
dd -bs 1m
will silently copy in 1-byte increments. This has caught
people by surprise. While we're at it, megabytes are
convenient, so let's have them too.
-rw-r--r-- | sys/src/cmd/dd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/src/cmd/dd.c b/sys/src/cmd/dd.c index ad433d8e1..6f0157bf4 100644 --- a/sys/src/cmd/dd.c +++ b/sys/src/cmd/dd.c @@ -353,7 +353,9 @@ number(vlong big) n = n*10 + *cs++ - '0'; for(;;) switch(*cs++) { - + case 'm': + n *= 1024*1024; + continue; case 'k': n *= 1024; continue; @@ -373,6 +375,9 @@ number(vlong big) exits("range"); } return n; + default: + fprint(2, "dd: invalid size suffix '%c'\n", cs[-1]); + exits("invalid"); } /* never gets here */ } |