File: path_max.diff

package info (click to toggle)
hdf5 1.14.5%2Brepack-3.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 208,864 kB
  • sloc: ansic: 715,772; f90: 42,941; java: 38,102; sh: 30,925; xml: 18,706; cpp: 18,011; makefile: 2,423; perl: 2,383; yacc: 332; python: 262; javascript: 203; lex: 157; ruby: 24; csh: 22
file content (58 lines) | stat: -rw-r--r-- 2,824 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: avoid the issue of PATH_MAX not being available on Hurd.
 Call realpath() the POSIX way, with NULL as second parameter so that
 the returned string is dynamically allocated. This way there is no
 more need for the strdup() call.
Author: Gilles Filippini <pini@debian.org>
Bug-Debian: http://bugs.debian.org/627896
Bug: HDFFV-9209
Index: hdf5/src/H5Fint.c
===================================================================
--- hdf5.orig/src/H5Fint.c
+++ hdf5/src/H5Fint.c
@@ -2786,10 +2786,6 @@ H5F__build_actual_name(const H5F_t *f, c
                        char **actual_name /*out*/)
 {
     hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */
-#ifdef H5_HAVE_SYMLINK
-    /* This has to be declared here to avoid unfreed resources on errors */
-    char *realname = NULL;      /* Fully resolved path name of file */
-#endif                          /* H5_HAVE_SYMLINK */
     herr_t ret_value = SUCCEED; /* Return value */
 
     FUNC_ENTER_PACKAGE
@@ -2824,10 +2820,6 @@ H5F__build_actual_name(const H5F_t *f, c
             h5_stat_t       fst;           /* Stat info from fstat() call */
             bool            want_posix_fd; /* Flag for retrieving file descriptor from VFD */
 
-            /* Allocate realname buffer */
-            if (NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char))))
-                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
-
             /* Perform a sanity check that the file or link wasn't switched
              * between when we opened it and when we called lstat().  This is
              * according to the security best practices for lstat() documented
@@ -2869,12 +2861,8 @@ H5F__build_actual_name(const H5F_t *f, c
                 HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "files' st_ino or st_dev fields changed!");
 
             /* Get the resolved path for the file name */
-            if (NULL == HDrealpath(name, realname))
+            if (NULL == (*actual_name = HDrealpath(name, NULL)))
                 HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve real path for file");
-
-            /* Duplicate the resolved path for the file name */
-            if (NULL == (*actual_name = (char *)H5MM_strdup(realname)))
-                HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate real path");
         } /* end if */
     }     /* end if */
 #endif    /* H5_HAVE_SYMLINK */
@@ -2891,10 +2879,6 @@ done:
     if (new_fapl_id > 0)
         if (H5I_dec_app_ref(new_fapl_id) < 0)
             HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL");
-#ifdef H5_HAVE_SYMLINK
-    if (realname)
-        realname = (char *)H5MM_xfree(realname);
-#endif /* H5_HAVE_SYMLINK */
 
     FUNC_LEAVE_NOAPI(ret_value)
 } /* H5F__build_actual_name() */