From 10ed03c6f54f3e6171f948243637462691f02e54 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 31 Aug 2017 08:51:01 +0100 Subject: 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 --- coreutils/dd.c | 6 +++--- 1 file 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) #if ENABLE_FEATURE_DD_IBS_OBS if (what == OP_ibs) { /* Must fit into positive ssize_t */ - ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); + ibs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); /*continue;*/ } if (what == OP_obs) { - obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); + obs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); /*continue;*/ } if (what == OP_conv) { @@ -364,7 +364,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) } #endif if (what == OP_bs) { - ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); + ibs = xatoul_range_sfx(val, 1, ULONG_MAX/2, cwbkMG_suffixes); obs = ibs; /*continue;*/ } -- cgit v1.2.3-55-g6feb