apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 60191] New: libapr computes incorrect size for dirent structure
Date Fri, 30 Sep 2016 09:35:42 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=60191

            Bug ID: 60191
           Summary: libapr computes incorrect size for dirent structure
           Product: APR
           Version: 1.5.2
          Hardware: PC
                OS: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: apyhalov@gmail.com

This is an upstream bug for https://www.illumos.org/issues/7394 . 

In apr_dir_open we have the following code: 

    /* On some platforms (e.g., Linux+GNU libc), d_name[] in struct 
     * dirent is declared with enough storage for the name.  On other
     * platforms (e.g., Solaris 8 for Intel), d_name is declared as a
     * one-byte array.  Note: gcc evaluates this at compile time.
     */
    apr_size_t dirent_size = 
        sizeof(*(*new)->entry) +
        (sizeof((*new)->entry->d_name) > 1 ? 0 : 255);


Which works incorrectly in both cases. On illumos SPARC this just allocates 0
bytes to directory names, on Intel (where d_name is char[1] - 255 bytes).
It should just use PATH_MAX+1 (on illumos PATH_MAX is 1024).
Something like this :

--- file_io/unix/dir.c.1        2016-09-30 11:54:20.721126026 +0300
+++ file_io/unix/dir.c  2016-09-30 12:01:08.345539555 +0300
@@ -78,7 +78,7 @@
      */
     apr_size_t dirent_size = 
         sizeof(*(*new)->entry) +
-        (sizeof((*new)->entry->d_name) > 1 ? 0 : 255);
+        PATH_MAX+1;
     DIR *dir = opendir(dirname);

     if (!dir) {

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message