[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] dd: do not unnecesarilly allocate memory for input block siz
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] dd: do not unnecesarilly allocate memory for input block size, when not needed |
Date: |
Fri, 22 May 2009 11:32:33 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Ondřej Vašík wrote:
> Hello,
> as reported in https://bugzilla.redhat.com/show_bug.cgi?id=502026, in dd
> is an unnecessary memory allocation for input block even if input block
> buffer is not needed (skip and count set to 0). Attached patch should
> prevent memory exhaustion error in that very special case. I guess
> mentioning in NEWS is not required in that case...
> diff --git a/src/dd.c b/src/dd.c
> index 3ba616b..be6d544 100644
> --- a/src/dd.c
> +++ b/src/dd.c
> @@ -1553,6 +1553,10 @@ dd_copy (void)
> int exit_status = EXIT_SUCCESS;
> size_t n_bytes_read;
>
> + /* Do not unnecessarily allocate memory */
> + if (max_records == 0 && skip_records == 0)
> + return exit_status;
So that would not run skip(STDOUT_FILENO,...) if count==0.
Would this break existing scripts that for example used
this command to position a non seekable device?
dd count=0 of=/dev/tape seek=1234
cheers,
Pádraig.