diff options
author | Ron Yorston <rmy@pobox.com> | 2017-08-31 08:51:01 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-08-31 08:51:01 +0100 |
commit | 10ed03c6f54f3e6171f948243637462691f02e54 (patch) | |
tree | 03662a1f32fd0426e532dc47478db76f0f4e3c7c | |
parent | 8731aec88d8efced67084446dea459bfcc3af1aa (diff) | |
download | busybox-w32-10ed03c6f54f3e6171f948243637462691f02e54.tar.gz busybox-w32-10ed03c6f54f3e6171f948243637462691f02e54.tar.bz2 busybox-w32-10ed03c6f54f3e6171f948243637462691f02e54.zip |
dd: silence warning on 64-bit systems
On 64-bit systems size_t may be larger than unsigned long, resulting in
a warning when -1L is cast to size_t.
There's little to be gained from allowing obs and ibs take values
larger than will fit in a signed long as the subsequent malloc will
probably fail. Limit their range to ULONG_MAX/2.
Signed-off-by: Ron Yorston <rmy@pobox.com>
-rw-r--r-- | coreutils/dd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index 9ea4897d5..14d270a1e 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -347,11 +347,11 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
347 | #if ENABLE_FEATURE_DD_IBS_OBS | 347 | #if ENABLE_FEATURE_DD_IBS_OBS |
348 | if (what == OP_ibs) { | 348 | if (what == OP_ibs) { |
349 | /* Must fit into positive ssize_t */ | 349 | /* Must fit into positive ssize_t */ |
350 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); | 350 | ibs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); |
351 | /*continue;*/ | 351 | /*continue;*/ |
352 | } | 352 | } |
353 | if (what == OP_obs) { | 353 | if (what == OP_obs) { |
354 | obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); | 354 | obs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); |
355 | /*continue;*/ | 355 | /*continue;*/ |
356 | } | 356 | } |
357 | if (what == OP_conv) { | 357 | if (what == OP_conv) { |
@@ -364,7 +364,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
364 | } | 364 | } |
365 | #endif | 365 | #endif |
366 | if (what == OP_bs) { | 366 | if (what == OP_bs) { |
367 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); | 367 | ibs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); |
368 | obs = ibs; | 368 | obs = ibs; |
369 | /*continue;*/ | 369 | /*continue;*/ |
370 | } | 370 | } |