summaryrefslogtreecommitdiff
path: root/libappstream-builder/asb-utils.c
diff options
context:
space:
mode:
authorMatthias Klumpp <matthias@tenstral.net>2014-11-03 19:45:49 +0100
committerRichard Hughes <richard@hughsie.com>2014-11-04 16:12:05 +0000
commit3b5399778818cc45ddefd9138a02b5ba2626a1d9 (patch)
tree30262fea21b7474ff4c5da978ac605afc5641bb9 /libappstream-builder/asb-utils.c
parent412d597d359707a0e1930a34d7c5e8689f0451d4 (diff)
downloadappstream-glib-3b5399778818cc45ddefd9138a02b5ba2626a1d9.tar.gz
Fix FTBFS on GNU/Hurd
Currently appstream-glib FTBFS on GNU/Hurd due to usage of PATH_MAX, which is not defined. The attached patch solves this problem by dynamically allocating strings of required length, and free them after usage if needed. Many thanks to Svante Signell for the initial patch!
Diffstat (limited to 'libappstream-builder/asb-utils.c')
-rw-r--r--libappstream-builder/asb-utils.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libappstream-builder/asb-utils.c b/libappstream-builder/asb-utils.c
index 2e10b96..6d2fbb6 100644
--- a/libappstream-builder/asb-utils.c
+++ b/libappstream-builder/asb-utils.c
@@ -234,10 +234,10 @@ static gboolean
asb_utils_explode_file (struct archive_entry *entry, const gchar *dir)
{
const gchar *tmp;
- gchar buf[PATH_MAX];
guint symlink_depth;
_cleanup_free_ gchar *back_up = NULL;
_cleanup_free_ gchar *path = NULL;
+ _cleanup_free_ gchar *buf = NULL;
/* no output file */
if (archive_entry_pathname (entry) == NULL)
@@ -246,33 +246,35 @@ asb_utils_explode_file (struct archive_entry *entry, const gchar *dir)
/* update output path */
tmp = archive_entry_pathname (entry);
path = asb_utils_sanitise_path (tmp);
- g_snprintf (buf, PATH_MAX, "%s%s", dir, path);
+ buf = g_build_filename (dir, path, NULL);
archive_entry_update_pathname_utf8 (entry, buf);
/* update hardlinks */
tmp = archive_entry_hardlink (entry);
if (tmp != NULL) {
+ _cleanup_free_ gchar *buf_link = NULL;
_cleanup_free_ gchar *path_link = NULL;
path_link = asb_utils_sanitise_path (tmp);
- g_snprintf (buf, PATH_MAX, "%s%s", dir, path_link);
- if (!g_file_test (buf, G_FILE_TEST_EXISTS)) {
+ buf_link = g_build_filename (dir, path_link, NULL);
+ if (!g_file_test (buf_link, G_FILE_TEST_EXISTS)) {
g_warning ("%s does not exist, cannot hardlink", tmp);
return FALSE;
}
- archive_entry_update_hardlink_utf8 (entry, buf);
+ archive_entry_update_hardlink_utf8 (entry, buf_link);
}
/* update symlinks */
tmp = archive_entry_symlink (entry);
if (tmp != NULL) {
+ _cleanup_free_ gchar *buf_link = NULL;
_cleanup_free_ gchar *path_link = NULL;
path_link = asb_utils_sanitise_path (tmp);
symlink_depth = asb_utils_count_directories_deep (path) - 1;
back_up = asb_utils_get_back_to_root (symlink_depth);
if (tmp[0] == '/')
tmp++;
- g_snprintf (buf, PATH_MAX, "%s%s", back_up, tmp);
- archive_entry_update_symlink_utf8 (entry, buf);
+ buf_link = g_build_filename (back_up, tmp, NULL);
+ archive_entry_update_symlink_utf8 (entry, buf_link);
}
return TRUE;
}