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

Re: Bug Report ...



Yves Martin has been quoted as saying:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>    I've no idea where to report my bug ... sorry
>    
>   FreeBSD Lib C Sources :
>     freebsd/src/lib/libc/gen/getcwd.c
> 
>   Line 214-215 ( from snapshot 20000202 )
>   Replace :
> 		bpt -= dp->d_namlen ;
> 		bcopy( dp->d_name, bpt, dp->d_namlen ) ;
>   By :
> 		bpt -= ( dp->d_namlen - 1 ) ;
> 		bcopy( dp->d_name, bpt, dp->d_namlen - 1 ) ;
> 
>   or else getcwd only returns the upper directory
>   after root.

     Thanks for tracking down the bug!  However, the actual bug isn't
in the freebsd libc code, it's most likely in the glue code for the
filesystem you're using.  Using (d_namlen - 1) makes no sense if
d_namlen is correct (it's the size of the string minus the terminating
nul, so you'd chop off the final character of the string).

     To help track this down, what filesystem are you using?  Memfs,
or one of the netbsd or linux filesystems?

     I was able to find a bug in the memfs code that would cause this
problem.  The netbsd and linux code looked correct, but I haven't
tested them.  If you're using memfs, try out this patch and see if it
fixes your problem:


*** oskit/memfs/memfs_com.c 1999/12/02 23:20:19     1.12
--- oskit/memfs/memfs_com.c 2000/04/05 16:41:34
***************
*** 743,749 ****
  #endif
  
                dirents->ino = (oskit_ino_t) b;
!               dirents->namelen = len;
        }
        *inout_ofs = 1;
        return 0;
--- 743,749 ----
  #endif
  
                dirents->ino = (oskit_ino_t) b;
!               dirents->namelen = len - 1;
        }
        *inout_ofs = 1;
        return 0;



steve

-- 
// stephen clawson				sclawson@cs.utah.edu
// university of utah			        


References: