Package: bmf
Severity: normal
Tags: upstream patch

Dear Maintainer,

Your package fails to build on Hurd. The attached patch fixes 
"30-compile-gnu-hurd.patch". Instead of defining PATH_MAX, it tries not to use 
this macro by allocating the exact amount of memory that is needed.

WBR,
Cyril Roelandt.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff --git a/debian/patches/30-compile-gnu-hurd.patch b/debian/patches/30-compile-gnu-hurd.patch
index be8b248..3d93a79 100644
--- a/debian/patches/30-compile-gnu-hurd.patch
+++ b/debian/patches/30-compile-gnu-hurd.patch
@@ -1,36 +1,69 @@
-From 50aa80ccf493f3c98bd2c7562daf79ce5ad5fab5 Mon Sep 17 00:00:00 2001
-From: Jari Aalto <jari.aa...@cante.net>
-Date: Sat, 16 Jan 2010 10:26:46 +0200
-Subject: [PATCH] dbdb.c: Define PATH_MAX (GNU Hurd)
-
-
-Signed-off-by: Jari Aalto <jari.aa...@cante.net>
----
- dbdb.c |   11 +++++++++++
- 1 files changed, 11 insertions(+), 0 deletions(-)
-
 diff --git a/dbdb.c b/dbdb.c
-index 8742dcc..7ee8249 100644
+index 8742dcc..87d8266 100644
 --- a/dbdb.c
 +++ b/dbdb.c
-@@ -18,6 +18,17 @@
- #include "dbh.h"
- #include "dbdb.h"
- 
-+/* PATH_MAX */
-+#include <limits.h>
-+
-+/*  PATH_MAX is only mandated by POSIX if there is a system limit for the
-+ *  maximum path length. This is not the case on GNU/Hurd.
-+ */
-+
-+#ifndef PATH_MAX
-+#define PATH_MAX 5000
-+#endif
-+
- #ifdef HAVE_LIBDB
- 
- #define DBT_init( pdbt ) memset( pdbt, 0, sizeof(DBT) )
--- 
-1.6.5
-
+@@ -178,7 +178,7 @@ dbt_t* dbdb_db_opentable( dbhdb_t* pthis, cpchar table, bool_t rdonly )
+     DBT         key;
+     DBT         val;
+ 
+-    char        szpath[PATH_MAX];
++    char*       szpath;
+ 
+     ptable = (dbtdb_t*)malloc( sizeof(dbtdb_t) );
+     if( ptable == NULL )
+@@ -194,6 +194,11 @@ dbt_t* dbdb_db_opentable( dbhdb_t* pthis, cpchar table, bool_t rdonly )
+     ptable->getcount = dbdb_table_getcount;
+     ptable->dbp = NULL;
+ 
++    szpath = malloc( strlen ( pthis->dir ) + strlen( table ) + 5 );
++    if( szpath == NULL )
++    {
++        return NULL;
++    }
+     sprintf( szpath, "%s/%s.db", pthis->dir, table );
+ #if !defined(DB_VERSION_MAJOR)
+     if( (dbp = dbopen( szpath, O_CREAT|O_RDWR, 0644, DB_BTREE, NULL)) == NULL )
+@@ -241,6 +246,7 @@ dbt_t* dbdb_db_opentable( dbhdb_t* pthis, cpchar table, bool_t rdonly )
+ 
+ bail:
+     free( ptable );
++    free( szpath );
+     return NULL;
+ }
+ 
+diff --git a/dbtext.c b/dbtext.c
+index 4914ef1..4af33f3 100644
+--- a/dbtext.c
++++ b/dbtext.c
+@@ -125,7 +125,7 @@ dbt_t* dbtext_db_opentable( dbhtext_t* pthis, cpchar table, bool_t rdonly )
+ #ifndef NOLOCK
+     struct flock    lock;
+ #endif /* ndef NOLOCK */
+-    char            szpath[PATH_MAX];
++    char*           szpath = NULL;
+     int             flags;
+     struct  stat    st;
+ 
+@@ -159,6 +159,11 @@ dbt_t* dbtext_db_opentable( dbhtext_t* pthis, cpchar table, bool_t rdonly )
+     ptable->nitems = 0;
+     ptable->pitems = NULL;
+ 
++    szpath = malloc ( strlen( pthis->dir ) + strlen( table ) + 6 );
++    if( szpath == NULL )
++    {
++        goto bail;
++    }
+     sprintf( szpath, "%s/%s.txt", pthis->dir, table );
+     flags = (rdonly ? O_RDONLY|O_CREAT : O_RDWR|O_CREAT);
+     ptable->fd = open( szpath, flags, 0644 );
+@@ -271,6 +276,10 @@ bail_uc:
+     ptable->fd = -1;
+ 
+ bail:
++    if( szpath != NULL )
++    {
++        free( szpath );
++    }
+     free( ptable );
+     return NULL;
+ }

Reply via email to