PATH_MAX + 1 in realpath_not_final()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux