diff --git a/subprojects/gstreamer/gst/gstregistry.c b/subprojects/gstreamer/gst/gstregistry.c index c84de1d7f62da6e35b49235e02a72dec424de290..2226d1853fbdf44171a17e6689ccd3d5543556b1 100644 --- a/subprojects/gstreamer/gst/gstregistry.c +++ b/subprojects/gstreamer/gst/gstregistry.c @@ -1599,6 +1599,8 @@ priv_gst_get_relocated_libgstreamer (void) #elif defined(HAVE_DLADDR) { Dl_info info; + char *real_fname = NULL; + long path_max = 0; GST_DEBUG ("attempting to retrieve libgstreamer-1.0 location using " "dladdr()"); @@ -1609,8 +1611,25 @@ priv_gst_get_relocated_libgstreamer (void) if (!info.dli_fname) { return NULL; } +#ifdef PATH_MAX + path_max = PATH_MAX; +#else + path_max = pathconf (info.dli_fname, _PC_PATH_MAX); + if (path_max <= 0) + path_max = 4096; +#endif + + real_fname = g_malloc (path_max); + if (realpath (info.dli_fname, real_fname)) { + dir = g_path_get_dirname (real_fname); + GST_DEBUG ("real directory location: %s", dir); + } else { + GST_ERROR ("could not canonicalize path %s: %s", info.dli_fname, + g_strerror (errno)); + dir = g_path_get_dirname (info.dli_fname); + } + g_free (real_fname); - dir = g_path_get_dirname (info.dli_fname); } else { GST_LOG ("dladdr() failed"); return NULL; diff --git a/subprojects/gstreamer/libs/gst/net/gstptpclock.c b/subprojects/gstreamer/libs/gst/net/gstptpclock.c index 09f482ecd1cf6539ad2449996544a9d33c9ff475..fc3268fae46ef1662676defcf24bfb47ea087eb4 100644 --- a/subprojects/gstreamer/libs/gst/net/gstptpclock.c +++ b/subprojects/gstreamer/libs/gst/net/gstptpclock.c @@ -2569,6 +2569,8 @@ get_relocated_libgstnet (void) #elif defined(HAVE_DLADDR) { Dl_info info; + char *real_fname = NULL; + long path_max = 0; GST_DEBUG ("attempting to retrieve libgstnet-1.0 location using " "dladdr()"); @@ -2579,8 +2581,25 @@ get_relocated_libgstnet (void) if (!info.dli_fname) { return NULL; } +#ifdef PATH_MAX + path_max = PATH_MAX; +#else + path_max = pathconf (info.dli_fname, _PC_PATH_MAX); + if (path_max <= 0) + path_max = 4096; +#endif + + real_fname = g_malloc (path_max); + if (realpath (info.dli_fname, real_fname)) { + dir = g_path_get_dirname (real_fname); + GST_DEBUG ("real directory location: %s", dir); + } else { + GST_ERROR ("could not canonicalize path %s: %s", info.dli_fname, + g_strerror (errno)); + dir = g_path_get_dirname (info.dli_fname); + } + g_free (real_fname); - dir = g_path_get_dirname (info.dli_fname); } else { GST_LOG ("dladdr() failed"); return NULL;