mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: overflow() at stdlib.h
Date: Thu, 12 Jul 2018 20:14:44 -0400	[thread overview]
Message-ID: <20180713001444.GZ1392@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAOs05YaDsSSctj=3che2OQ7Gqjd919NVsd_H=y1cbt0vDkH4aw@mail.gmail.com>

On Thu, Jul 12, 2018 at 07:55:56PM +0530, m0rtal f!w wrote:
> Team,
> 
> File: stdlib.h#L:113
> 
> i.e
> char *realpath (const char *__restrict, char *__restrict);
> 
> According to the documentation of realpath() the output buffer needs to be
> at least of size PATH_MAX specifying output buffers large enough to handle
> the maximum-size possible result from path manipulation functions. (In that
> instance, buf's size comes from uv__fs_pathmax_size(). That function
> attempts to use pathconf(path, _PC_PATH_MAX) as noted in the realpath(3)
> docs)

There is no provision in the specification of realpath for use of
pathconf or other facilities for determining a maximum buffer size;
the resolved_name buffer argument must either point to an array of at
least PATH_MAX size, or must be a null pointer, in which case realpath
will allocate storage. Only the latter option when the implementation
does not define PATH_MAX, but musl always defines PATH_MAX.

> But over here uv__fs_pathmax_size() nor pathconf(path, _PC_PATH_MAX) is
> used.

I don't understand what you mean by "is used" here. The only file you
cited is header declarations only, no code, and the declaration is
exactly the only thing it's permitted to be (the one mandated by the
standard).

> Passing an inadequately-sized output buffer to a path manipulation function
> can result in a buffer overflow. Such functions include realpath()
> readlink() PathAppend() and others.
> 
> Request team to have a look and validate.

If an application is not passing an adequately-sized (note: this means
PATH_MAX, not anything else!) buffer, that is an application bug and
the application has undefined behavior.

Rich


      parent reply	other threads:[~2018-07-13  0:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 14:25 m0rtal f!w
2018-07-12 15:42 ` Szabolcs Nagy
2018-07-12 15:51   ` Dhiraj
2018-07-12 16:30     ` Szabolcs Nagy
2018-07-12 16:35       ` Dhiraj
2018-07-13  0:14 ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180713001444.GZ1392@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).