aboutsummaryrefslogtreecommitdiff
path: root/coreutils/dd.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/dd.c')
-rw-r--r--coreutils/dd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 5281d8118..381f60075 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -286,25 +286,26 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
286 } 286 }
287 287
288 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { 288 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
289 if (flags & FLAG_NOERROR) /* Pre-zero the buffer if conv=noerror */
290 memset(ibuf, 0, ibs);
291 n = safe_read(ifd, ibuf, ibs); 289 n = safe_read(ifd, ibuf, ibs);
292 if (n == 0) 290 if (n == 0)
293 break; 291 break;
294 if (n < 0) { 292 if (n < 0) {
293 /* "Bad block" */
295 if (!(flags & FLAG_NOERROR)) 294 if (!(flags & FLAG_NOERROR))
296 goto die_infile; 295 goto die_infile;
297 n = ibs;
298 bb_simple_perror_msg(infile); 296 bb_simple_perror_msg(infile);
299 /* GNU dd with conv=noerror skips over "bad blocks" */ 297 /* GNU dd with conv=noerror skips over bad blocks */
300 xlseek(ifd, ibs, SEEK_CUR); 298 xlseek(ifd, ibs, SEEK_CUR);
299 /* conv=noerror,sync writes NULs,
300 * conv=noerror just ignores input bad blocks */
301 n = 0;
301 } 302 }
302 if ((size_t)n == ibs) 303 if ((size_t)n == ibs)
303 G.in_full++; 304 G.in_full++;
304 else { 305 else {
305 G.in_part++; 306 G.in_part++;
306 if (flags & FLAG_SYNC) { 307 if (flags & FLAG_SYNC) {
307 memset(ibuf + n, '\0', ibs - n); 308 memset(ibuf + n, 0, ibs - n);
308 n = ibs; 309 n = ibs;
309 } 310 }
310 } 311 }