Bug in bsd-misc.c

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Tue Mar 13 08:51:45 EST 2001


On Mon, 12 Mar 2001 wwieser at gmx.de wrote:

> Hi guys...
> 
> Just wanted to see what is so different in BSD from Linux and had a 
> quick look at the openbsd-compat directory (openssh-2.5.1p1). 
> 
> There is a REALLY obvious bug in bsd-misc.c, quoted below: 
> 
> #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && 
> defined(HAVE_SYS_NERR)
> const char *strerror(int e)
> {
>         extern int sys_nerr;
>         extern char *sys_errlist[];
>         
>         if ((e >= 0) || (e < sys_nerr))
>                 return("unlisted error");
>         else
>                 return(sys_errlist[e]);
> }
> #endif
> 
> (Shouldn't the return statements be swapped?!) 
> 

I believe so.  

Looking at:

http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/__strerror.c?rev=1.6


It seems that they should be.

However, I'm interested in how you ran across this with Linux since Linux
has a built in strerror(). =)

- Ben






More information about the openssh-unix-dev mailing list