All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@vger.kernel.org
Subject: PATH_MAX + 1 in realpath_not_final()
Date: Tue, 07 Sep 2021 12:38:04 +0200	[thread overview]
Message-ID: <87czpkacxf.fsf@redhat.com> (raw)

Hello,

I was asked whether is there a reason for "Resolved path must be a path
of size PATH_MAX + 1" in the comment assigned to real_path_not_final()
in selinux.h [1]?

    /* Resolve all of the symlinks and relative portions of a pathname, but NOT
     * the final component (same a realpath() unless the final component is a
     * symlink.  Resolved path must be a path of size PATH_MAX + 1 */
    extern int realpath_not_final(const char *name, char *resolved_path);


Looking into libselinux/src/matchpathcon.c:

 423 │   len = strlen(p);                     
 424 │   if (len + strlen(last_component) + 2 > PATH_MAX) {
 425 │   │   myprintf("symlink_realpath(%s) failed: Filename too long \n",
 426 │   │   │ name);                   
 427 │   │   errno = ENAMETOOLONG;               
 428 │   │   rc = -1;                  
 429 │   │   goto out;                  
 430 │   }


it seems to be that PATH_MAX should be enough? Am I missing something?


[1] https://github.com/SELinuxProject/selinux/blob/master/libselinux/include/selinux/selinux.h#L493

Thanks,

Petr


                 reply	other threads:[~2021-09-07 10:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87czpkacxf.fsf@redhat.com \
    --to=plautrba@redhat.com \
    --cc=selinux@vger.kernel.org \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.