bug-bash
[Top][All Lists]
Advanced

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

Re: bash-4.2: poor order of conditionals


From: Chet Ramey
Subject: Re: bash-4.2: poor order of conditionals
Date: Wed, 26 Oct 2011 16:11:02 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

On 10/25/11 4:54 PM, David Binderman wrote:
> 
> 
> Hello there,
> 
> I just ran the static analysis tool cppcheck over the source
> code of bash-4.2
> 
> It said
> 
> [bash-4.2/builtins/mkbuiltins.c:554]: (style) Array index i is used before 
> limits check
> 
> The source code is
> 
>       while (buffer[i] != '\n' && i < file_size)
>         i++;
> 
> You might be better off with
> 
>       while (i < file_size && buffer[i] != '\n')
>         i++;

Thanks for the report.  I'd be interested in other issues that tool
reports.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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