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

Bug#648187: mx: FTBFS on hurd-i386



Package: mx
Version: 1.3.1-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

The attached patch solves the FTBFS problems of mx on GNU/Hurd. Dynamic
memory allocation is used to avoid the absence of a PATH_MAX definition
for GNU/Hurd. The glib versions of malloc and free are utilized.

Thanks!


diff -ur mx-1.3.1/mx/mx-create-image-cache.c mx-1.3.1.modified/mx/mx-create-image-cache.c
--- mx-1.3.1/mx/mx-create-image-cache.c	2011-08-11 18:12:29.000000000 +0200
+++ mx-1.3.1.modified/mx/mx-create-image-cache.c	2011-11-09 12:51:51.000000000 +0100
@@ -417,7 +417,8 @@
                              char *pngfile)
 {
   FILE *file;
-  char filename[PATH_MAX *2];
+  char *filename = NULL;
+  int len = 0;
   struct imgcache_element element;
   struct imgcache_element *elm;
   GList *item;
@@ -426,11 +427,14 @@
 
   strcpy(&element.filename[0], pngfile);
 
+  len = strlen (directory) + 9;
+  filename = g_malloc (len + 1);
   sprintf(filename, "%s/mx.cache", directory);
 
   file = fopen(filename, "w");
   if (!file) {
       fprintf(stderr, "Cannot write cache file: %s\n", filename);
+      g_free (filename);
       return;
     }
   fwrite(&element, 1, sizeof(element), file);
@@ -442,6 +446,7 @@
       elm->ptr = NULL;
       fwrite(elm, 1, sizeof(element), file);
     }
+  g_free (filename);
   fclose(file);
 
 }
@@ -449,7 +454,9 @@
 int main(int    argc,
          char **argv)
 {
-  char image_file[PATH_MAX];
+  char *image_file = NULL;
+  int len = 0;
+
   if (argc <= 1) {
       printf("Usage:\n\t\tmakecache <directory>\n");
       return EXIT_FAILURE;
@@ -457,8 +464,11 @@
   g_type_init();
   makecache(argv[1], 1);
   optimal_placement();
+  len = sizeof (guint) + 18;
+  image_file = g_malloc (len + 1);
   sprintf(image_file, "/var/cache/mx/%08x.png", g_str_hash(argv[1]));
   if (make_final_image(image_file))
     write_cache_file(argv[1], image_file);
+  g_free (image_file);
   return EXIT_SUCCESS;
 }

Reply to: