summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-10-06 16:17:56 +0000
committerJim Meyering <jim@meyering.net>2002-10-06 16:17:56 +0000
commit647b7376482c2e36930139a8b47ed2f999a02723 (patch)
tree1cb8639978590d7f4ec14eb871cbb0f1e589b8ca
parent00ebca59b7e8963e44180cbf3a0bdc22f6d67ffd (diff)
downloadcoreutils-647b7376482c2e36930139a8b47ed2f999a02723.tar.xz
(scanargs): Ensure that specified block sizes (specified
via ibs=N, obs=N, and bs=N) are no larger than SSIZE_MAX. (skip, dd_copy): Adapt to new safe_read ABI.
-rw-r--r--src/dd.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dd.c b/src/dd.c
index 1b1b29106..aa0b3beed 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -574,18 +574,24 @@ scanargs (int argc, char **argv)
if (STREQ (name, "ibs"))
{
+ /* Ensure that each blocksize is <= SSIZE_MAX. */
+ invalid |= SSIZE_MAX < n;
input_blocksize = n;
invalid |= input_blocksize != n || input_blocksize == 0;
conversions_mask |= C_TWOBUFS;
}
else if (STREQ (name, "obs"))
{
+ /* Ensure that each blocksize is <= SSIZE_MAX. */
+ invalid |= SSIZE_MAX < n;
output_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
conversions_mask |= C_TWOBUFS;
}
else if (STREQ (name, "bs"))
{
+ /* Ensure that each blocksize is <= SSIZE_MAX. */
+ invalid |= SSIZE_MAX < n;
output_blocksize = input_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
}
@@ -806,8 +812,8 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
{
while (records--)
{
- ssize_t nread = safe_read (fdesc, buf, blocksize);
- if (nread < 0)
+ size_t nread = safe_read (fdesc, buf, blocksize);
+ if (nread == SAFE_READ_ERROR)
{
error (0, errno, _("reading %s"), quote (file));
quit (1);
@@ -923,7 +929,7 @@ dd_copy (void)
char *ibuf, *bufstart; /* Input buffer. */
char *real_buf; /* real buffer address before alignment */
char *real_obuf;
- ssize_t nread; /* Bytes read in the current block. */
+ size_t nread; /* Bytes read in the current block. */
int exit_status = 0;
size_t page_size = getpagesize ();
size_t n_bytes_read;
@@ -1001,7 +1007,7 @@ dd_copy (void)
if (nread == 0)
break; /* EOF. */
- if (nread < 0)
+ if (nread == SAFE_READ_ERROR)
{
error (0, errno, _("reading %s"), quote (input_file));
if (conversions_mask & C_NOERROR)