This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ada] Move and rename max_path_len
- From: Geert Bosch <bosch at gnat dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 May 2002 14:01:40 -0400
- Subject: Re: [Ada] Move and rename max_path_len
On Sunday, May 19, 2002, at 05:40 , Florian Weimer wrote:
> The following change prepares fixing the buffer overflow bug in
> adaint.c:__gnat_tmp_name(). We need to access max_path_len in this
> file, but cstreams.c is not always linked in, that's why I moved it to
> adaint.c. In addition, max_path_len is in the user namespace, which
> is a no-no for such an identifier, that's why I prepended "__gnat_".
This change is OK to apply. Indeed, the max_path_len is bad. The move
to adaint.c seems reasonable. In the longer term we really should move
all of the interfacing between the Ada part of the run time and external
libraries into
> Note that POSIX does not require that an upper bound for the path name
> length exists, so all code that uses __gnat_max_path_len is inherently
> unportable. Each time we pass a path name from C to Ada, we should
> probably use malloc()ed storage some day.
In most cases it would be possible to first calculate the actual length
of the path and then use alloca to allocate just the right amount of
storage. Apart from that, what we really should do is clearly define
the interface (in the form of package specs) between the Ada run time
and the libraries it depends on and then rewrite the implementation and
then disallow directly interfacing to C in other places of the run time.
-Geert