coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-8.14.116-1e18d on NetBSD 5.1 - split bug


From: Pádraig Brady
Subject: Re: coreutils-8.14.116-1e18d on NetBSD 5.1 - split bug
Date: Thu, 05 Jan 2012 11:11:14 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 01/05/2012 02:32 AM, Bruno Haible wrote:
>>   http://meyering.net/cu/coreutils-8.14.116-1e18d.tar.xz
> 
> On NetBSD 5.1/x86, I get this test failure in particular:
> 
> 
> FAIL: split/l-chunk
> ===================
> split: /dev/zero: No such file or directory
> stat: cannot stat `x*': No such file or directory
> rm: cannot remove `x??': No such file or directory
> 
> 
> The first among these messages comes from this command:
> $ ./split -n l/2 /dev/zero
> ./split: /dev/zero: No such file or directory
> 
> Single-stepping it, it gets to call
> lines_chunk_split (k=0, n=2, buf=0x7f7ffda01000 "", bufsize=65536, 
> file_size=2)
> and at split.c:625 the call
>   full_read (STDIN_FILENO, buf, bufsize)
> returns 65536, the same value as bufsize. The code in line 627 is buggy:
> It uses errno even when full_read returned bufsize. But that value is
> undefined.
> 
> This patch fixes the bug and make the test succeed:

Nice one Bruno, thanks!

> 2012-01-04  Bruno Haible  <address@hidden>
> 
>       split: Avoid failure due to leftover 'errno' value.
>       * src/split.c (lines_chunk_split): Fix logic.
> 
> --- src/split.c.bak     2012-01-05 03:03:16.000000000 +0100
> +++ src/split.c 2012-01-05 03:25:31.000000000 +0100
> @@ -623,11 +623,11 @@
>      {
>        char *bp = buf, *eob;
>        size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
> -      n_read = MIN (n_read, file_size - n_written);
>        if (n_read < bufsize && errno)
>          error (EXIT_FAILURE, errno, "%s", infile);
>        else if (n_read == 0)
>          break; /* eof.  */
> +      n_read = MIN (n_read, file_size - n_written);
>        chunk_truncated = false;
>        eob = buf + n_read;

Hmm, I wonder should full_read() be adjusting the errno?
I.E. maybe the behavior of read() and full_read() should
be different, as the latter can do a successful partial read(),
and then have a failure. So it should be possible to assume
n_read >-1 and a valid errno?

Anyway I'm rushing now, so I'll look at this later.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]