diff options
author | Matthias Klumpp <matthias@tenstral.net> | 2014-11-03 19:45:49 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-11-04 16:12:05 +0000 |
commit | 3b5399778818cc45ddefd9138a02b5ba2626a1d9 (patch) | |
tree | 30262fea21b7474ff4c5da978ac605afc5641bb9 | |
parent | 412d597d359707a0e1930a34d7c5e8689f0451d4 (diff) | |
download | appstream-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!
-rw-r--r-- | client/as-util.c | 20 | ||||
-rw-r--r-- | libappstream-builder/asb-utils.c | 16 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-gstreamer.c | 4 |
3 files changed, 23 insertions, 17 deletions
diff --git a/client/as-util.c b/client/as-util.c index 2007b32..97183a8 100644 --- a/client/as-util.c +++ b/client/as-util.c @@ -825,9 +825,9 @@ static gboolean as_util_install_icons (const gchar *filename, const gchar *origin, GError **error) { const gchar *destdir; + const gchar *pathname; const gchar *tmp; gboolean ret = TRUE; - gchar buf[PATH_MAX]; gsize len; int r; struct archive *arch = NULL; @@ -861,6 +861,8 @@ as_util_install_icons (const gchar *filename, const gchar *origin, GError **erro /* decompress each file */ for (;;) { + _cleanup_free_ gchar *buf = NULL; + r = archive_read_next_header (arch, &entry); if (r == ARCHIVE_EOF) break; @@ -875,26 +877,28 @@ as_util_install_icons (const gchar *filename, const gchar *origin, GError **erro } /* no output file */ - if (archive_entry_pathname (entry) == NULL) + pathname = archive_entry_pathname (entry); + if (pathname == NULL) continue; /* update output path */ - g_snprintf (buf, PATH_MAX, "%s/%s", - dir, archive_entry_pathname (entry)); + buf = g_build_filename (dir, pathname, NULL); archive_entry_update_pathname_utf8 (entry, buf); /* update hardlinks */ tmp = archive_entry_hardlink (entry); if (tmp != NULL) { - g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp); - archive_entry_update_hardlink_utf8 (entry, buf); + _cleanup_free_ gchar *buf_link = NULL; + buf_link = g_build_filename (dir, tmp, NULL); + archive_entry_update_hardlink_utf8 (entry, buf_link); } /* update symlinks */ tmp = archive_entry_symlink (entry); if (tmp != NULL) { - g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp); - archive_entry_update_symlink_utf8 (entry, buf); + _cleanup_free_ gchar *buf_link = NULL; + buf_link = g_build_filename (dir, tmp, NULL); + archive_entry_update_symlink_utf8 (entry, buf_link); } r = archive_read_extract (arch, entry, 0); 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; } diff --git a/libappstream-builder/plugins/asb-plugin-gstreamer.c b/libappstream-builder/plugins/asb-plugin-gstreamer.c index b205f3a..d3c936c 100644 --- a/libappstream-builder/plugins/asb-plugin-gstreamer.c +++ b/libappstream-builder/plugins/asb-plugin-gstreamer.c @@ -111,8 +111,8 @@ static const AsbGstreamerDescData data[] = { static gboolean asb_utils_is_file_in_tmpdir (const gchar *tmpdir, const gchar *filename) { - gchar tmp[PATH_MAX]; - g_snprintf (tmp, PATH_MAX, "%s/%s", tmpdir, filename); + _cleanup_free_ gchar *tmp = NULL; + tmp = g_build_filename (tmpdir, filename, NULL); return g_file_test (tmp, G_FILE_TEST_EXISTS); } |