[hackers] [sbase] dd: Always move excess to beginning of buffer after read/write loops || Michael Forney

From: <git_AT_suckless.org>
Date: Wed, 16 Jun 2021 09:48:17 +0200 (CEST)

commit 4b76652eff2b6f7d23c800dbc48c509792c726b3
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Wed Apr 28 01:41:26 2021 -0700
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Fri May 21 12:16:41 2021 -0700

    dd: Always move excess to beginning of buffer after read/write loops
    
    Otherwise, while we may have enough room for at least one input
    block, we may not have enough room for an output block.

diff --git a/dd.c b/dd.c
index 5522db5..6061048 100644
--- a/dd.c
+++ b/dd.c
_AT_@ -222,11 +222,10 @@ main(int argc, char *argv[])
                                 ofull++;
                         opos += ret;
                 } while ((eof && ipos < opos) || (!eof && ipos - opos >= obs));
- if (len - ipos < ibs) {
+ if (opos < ipos)
                         memmove(buf, buf + opos, ipos - opos);
- ipos -= opos;
- opos = 0;
- }
+ ipos -= opos;
+ opos = 0;
         }
         summary();
 
Received on Wed Jun 16 2021 - 09:48:17 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 16 2021 - 09:48:35 CEST