[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

appstream-glib: FTBFS on hurd-i396 (for review)



Source: appstream-glib
Version: 0.3.0-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

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.

Thanks!

(comments welcomed!)
--- a/client/as-util.c	2014-08-28 12:32:32.000000000 +0200
+++ b/client/as-util.c	2014-10-21 10:40:08.000000000 +0200
@@ -767,9 +767,9 @@
 as_util_install_icons (const gchar *filename, const gchar *origin, GError **error)
 {
 	const gchar *destdir;
-	const gchar *tmp;
+	const gchar *tmp, *pathname = NULL;
 	gboolean ret = TRUE;
-	gchar buf[PATH_MAX];
+	gchar *buf = NULL;
 	gsize len;
 	int r;
 	struct archive *arch = NULL;
@@ -817,28 +817,36 @@
 		}
 
 		/* 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));
+		len = strlen (dir) + 1 + strlen (pathname) + 1;
+		buf = g_malloc(len);
+		g_snprintf (buf, len, "%s/%s",
+			    dir, pathname);
 		archive_entry_update_pathname_utf8 (entry, buf);
 
 		/* update hardlinks */
 		tmp = archive_entry_hardlink (entry);
+		len = strlen (dir) + 1 + strlen (tmp) + 1;
+		buf = g_realloc (buf, len);
 		if (tmp != NULL) {
-			g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
+			g_snprintf (buf, len, "%s/%s", dir, tmp);
 			archive_entry_update_hardlink_utf8 (entry, buf);
 		}
 
 		/* update symlinks */
 		tmp = archive_entry_symlink (entry);
+		len = strlen (dir) + 1 + strlen (tmp) + 1;
+		buf = g_realloc (buf, len);
 		if (tmp != NULL) {
-			g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
+			g_snprintf (buf, len, "%s/%s", dir, tmp);
 			archive_entry_update_symlink_utf8 (entry, buf);
 		}
 
+		g_free (buf);
 		r = archive_read_extract (arch, entry, 0);
 		if (r != ARCHIVE_OK) {
 			ret = FALSE;
--- a/libappstream-builder/asb-utils.c	2014-08-26 10:40:10.000000000 +0200
+++ b/libappstream-builder/asb-utils.c	2014-10-21 10:38:33.000000000 +0200
@@ -184,7 +184,8 @@
 			GPtrArray *glob)
 {
 	const gchar *tmp;
-	gchar buf[PATH_MAX];
+	gsize len;
+	gchar *buf = NULL;
 	_cleanup_free_ gchar *path = NULL;
 
 	/* no output file */
@@ -206,22 +207,29 @@
 	}
 
 	/* update output path */
-	g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
+	len = strlen (dir) + 1 + strlen(tmp) + 1;
+	buf = g_malloc (len);
+	g_snprintf (buf, len, "%s/%s", dir, tmp);
 	archive_entry_update_pathname_utf8 (entry, buf);
 
 	/* update hardlinks */
 	tmp = archive_entry_hardlink (entry);
+	len = strlen (dir) + 1 + strlen(tmp) + 1;
+	buf = g_realloc (buf, len);
 	if (tmp != NULL) {
-		g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
+		g_snprintf (buf, len, "%s/%s", dir, tmp);
 		archive_entry_update_hardlink_utf8 (entry, buf);
 	}
 
 	/* update symlinks */
 	tmp = archive_entry_symlink (entry);
+	len = strlen (dir) + 1 + strlen(tmp) + 1;
+	buf = g_realloc (buf, len);
 	if (tmp != NULL) {
-		g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
+		g_snprintf (buf, len, "%s/%s", dir, tmp);
 		archive_entry_update_symlink_utf8 (entry, buf);
 	}
+	free (buf);
 	return TRUE;
 }
 
--- a/libappstream-builder/plugins/asb-plugin-gstreamer.c	2014-08-19 12:27:06.000000000 +0200
+++ b/libappstream-builder/plugins/asb-plugin-gstreamer.c	2014-10-21 10:42:39.000000000 +0200
@@ -111,8 +111,9 @@
 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);
+	gsize len = strlen (tmpdir) + 1 + strlen (filename) + 1;
+	gchar tmp = g_malloc (len);
+	g_snprintf (tmp, len, "%s/%s", tmpdir, filename);
 	return g_file_test (tmp, G_FILE_TEST_EXISTS);
 }
 

Reply to: