Source: ros-rospack Version: 2.2.5-3 Severity: important Tags: patch Usertags: hurd User: debian-h...@lists.debian.org
Hello, Currently ros-rospack FTBFS on GNU/Hurd due to usage of PATH_MAX, which is not defined. The attached patch fixes this for all UNIX cases by dynamically allocating and de-allocating the needed strings. The patch works fine for UNIX, but has not been tested if the WIN32 or MINGW32 versions are affected. In case of any doubts about the patch, please forward this patch to the upstream authors, so I can communicate directly with them. Thanks!
Index: ros-rospack-2.2.5/src/rospack.cpp =================================================================== --- ros-rospack-2.2.5.orig/src/rospack.cpp +++ ros-rospack-2.2.5/src/rospack.cpp @@ -2011,11 +2011,14 @@ Rosstackage::writeCache() } else { - char tmp_cache_dir[PATH_MAX]; - char tmp_cache_path[PATH_MAX]; - strncpy(tmp_cache_dir, cache_path.c_str(), sizeof(tmp_cache_dir)); + int len = cache_path.size() + 1; + char *tmp_cache_dir = (char *)malloc(len); + strncpy(tmp_cache_dir, cache_path.c_str(), len); + // make sure tmp_cache_dir is NULL terminated + tmp_cache_dir[len - 1] = '\0'; #if defined(_MSC_VER) // No dirname on Windows; use _splitpath_s instead + char tmp_cache_path[PATH_MAX]; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; _splitpath_s(tmp_cache_dir, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); @@ -2023,11 +2026,18 @@ Rosstackage::writeCache() _makepath_s(full_dir, _MAX_DRIVE + _MAX_DIR, drive, dir, NULL, NULL); snprintf(tmp_cache_path, sizeof(tmp_cache_path), "%s\\.rospack_cache.XXXXXX", full_dir); #elif defined(__MINGW32__) + char tmp_cache_path[PATH_MAX]; char* temp_name = tempnam(dirname(tmp_cache_dir),".rospack_cache."); snprintf(tmp_cache_path, sizeof(tmp_cache_path), temp_name); delete temp_name; #else - snprintf(tmp_cache_path, sizeof(tmp_cache_path), "%s/.rospack_cache.XXXXXX", dirname(tmp_cache_dir)); + char *tmp_cache_path = NULL; + char *temp_dirname = strdup(dirname(tmp_cache_dir)); + free(tmp_cache_dir); + len = strlen(temp_dirname) + 22 + 1; + tmp_cache_path = (char *)malloc(len); + snprintf(tmp_cache_path, len, "%s/.rospack_cache.XXXXXX", temp_dirname); + free(temp_dirname); #endif #if defined(__MINGW32__) // There is no equivalent of mkstemp or _mktemp_s on mingw, so we resort to a slightly problematic @@ -2085,6 +2095,9 @@ Rosstackage::writeCache() } } } +#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(WIN32) + free(tmp_cache_path); +#endif } }