From: Jim Meyering Date: Thu, 25 Aug 1994 13:28:58 +0000 (+0000) Subject: . X-Git-Tag: textutils-1_12_1~625 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=326b01a32791afa28a614e5eb3522a7a71ad1d8d;p=thirdparty%2Fcoreutils.git . --- diff --git a/src/dd.c b/src/dd.c index 8f93cbbc29..881af94e43 100644 --- a/src/dd.c +++ b/src/dd.c @@ -76,6 +76,8 @@ #define ISUPPER(c) (isascii (c) && isupper (c)) #define ISDIGIT(c) (isascii (c) && isdigit (c)) +#define SWAB_ALIGN_OFFSET 2 + #include #include #include @@ -551,10 +553,14 @@ copy () int nread; /* Bytes read in the current block. */ int exit_status = 0; - /* Leave an extra byte at the beginning and end of `ibuf' for conv=swab, - but keep the buffer address even. Some peculiar device drivers work - only with word-aligned buffers. */ - ibuf = (unsigned char *) xmalloc (input_blocksize + 4) + 2; + /* Leave at least one extra byte at the beginning and end of `ibuf' + for conv=swab, but keep the buffer address even. But some peculiar + device drivers work only with word-aligned buffers, so leave an + extra two bytes. */ + + ibuf = (unsigned char *) xmalloc (input_blocksize + 2 * SWAB_ALIGN_OFFSET); + ibuf += SWAB_ALIGN_OFFSET; + if (conversions_mask & C_TWOBUFS) obuf = (unsigned char *) xmalloc (output_blocksize); else @@ -698,7 +704,7 @@ copy () } } - free (ibuf - 1); + free (ibuf - SWAB_ALIGN_OFFSET); if (obuf != ibuf) free (obuf);