From: Denys Vlasenko Date: Mon, 19 Aug 2013 07:00:08 +0000 (+0200) Subject: dd: do not reuse local variables for unrelated values. X-Git-Tag: 1_22_0~107 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4b1896cd2ccdb3e09070035f86a48d42b678d8ff;p=oweals%2Fbusybox.git dd: do not reuse local variables for unrelated values. Signed-off-by: Denys Vlasenko --- diff --git a/coreutils/dd.c b/coreutils/dd.c index 96602ebdd..9cb96bb06 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -201,7 +201,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) }; int exitcode = EXIT_FAILURE; size_t ibs = 512, obs = 512; - ssize_t n, w; + int i; char *ibuf, *obuf; /* And these are all zeroed at once! */ struct { @@ -223,10 +223,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv) INIT_G(); //fflush_all(); - is this needed because of NOEXEC? - for (n = 1; argv[n]; n++) { + for (i = 1; argv[i]; i++) { int what; char *val; - char *arg = argv[n]; + char *arg = argv[i]; #if ENABLE_DESKTOP /* "dd --". NB: coreutils 6.9 will complain if they see @@ -300,7 +300,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) outfile = val; /*continue;*/ } - } /* end of "for (argv[n])" */ + } /* end of "for (argv[i])" */ //XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever ibuf = obuf = xmalloc(ibs); @@ -347,7 +347,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) if (skip) { if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { while (skip-- > 0) { - n = safe_read(ifd, ibuf, ibs); + ssize_t n = safe_read(ifd, ibuf, ibs); if (n < 0) goto die_infile; if (n == 0) @@ -361,6 +361,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv) } while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { + ssize_t n; + n = safe_read(ifd, ibuf, ibs); if (n == 0) break; @@ -411,7 +413,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) } if (ENABLE_FEATURE_DD_IBS_OBS && oc) { - w = full_write_or_warn(obuf, oc, outfile); + ssize_t w = full_write_or_warn(obuf, oc, outfile); if (w < 0) goto out_status; if (w > 0) G.out_part++; }