This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]