PATCH: fix buffer overrun in natFile.cc

Bryce McKinlay bryce@waitaki.otago.ac.nz
Tue May 29 21:29:00 GMT 2001


Jeff Sturm wrote:

> On sparc-solaris, I find File.list() somtimes dumps core, for instance if
> libgcj is compiled with -O0.  In natFile.cc we have
>
>     struct dirent *d, d2;
>     while ((d = get_entry (dir, &d2)) != NULL)
>
> and
>
>   static struct dirent *
>   get_entry (DIR *dir, struct dirent *e)
>   {
>     struct dirent *r;
>     if (readdir_r (dir, e, &r) || r == NULL)
>
> but the info page for readdir_r says `e' must be at least (sizeof (struct
> dirent) + NAME_MAX + 1) bytes.  Oops.

Should we really be using these *_r functions anyway? In glibc I get the
impression that they are really only there for backwards compatibility, and I have
a feeling that they are generally less tested and more buggy than the normal ones.
Are there really any platforms out there that still don't have threadsafe
implementations of the "normal" IO routines?

regards

  [ bryce ]




More information about the Java-patches mailing list