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

Re: Bug#641028: libdvdnav: FTBFS on hurd-i386



On Fri, 2011-09-09 at 17:29:58 +0200, Svante Signell wrote:
> Package: libdvdnav
> Version: 4.1.4-1219
> Severity: important
> Tags: patch
> User: debian-hurd@lists.debian.org
> Usertags: hurd

> The libdvdnav package currently fails to build from source on the Hurd due
> to a condition missing to define MAXPATHLEN. The patch below fixes this issue.
> 
> diff -ur libdvdnav-4.1.4-1219/src/remap.c libdvdnav-4.1.4-1219.modified//src/remap.c
> --- libdvdnav-4.1.4-1219/src/remap.c	2008-12-30 15:48:46.000000000 +0100
> +++ libdvdnav-4.1.4-1219.modified//src/remap.c	2011-09-09 17:11:47.000000000 +0200
> @@ -27,6 +27,9 @@
>  #ifndef _MSC_VER
>  #include <sys/param.h>
>  #include <sys/fcntl.h>
> +#ifdef __GNU__ 
> +#define MAXPATHLEN 255
> +#endif
>  #else
>  #ifndef MAXPATHLEN
>  #define MAXPATHLEN 255

Removing the arbitrary path limits seems more correct to me, here's a
patch doing that, only build tested.

The change in dvdnav_s should be safe as that's an opaque data type,
used through pointers, which should not be exposed to applications.

thanks,
guillem
>From ea5682d40ba7ed027c5bc6770a1195bccc270ea8 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Sat, 10 Sep 2011 03:28:51 +0200
Subject: [PATCH] Use dynamically allocated strings instead of hardcoded size
 ones

---
 src/dvdnav.c          |    3 +--
 src/dvdnav_internal.h |    9 +--------
 src/remap.c           |   13 +++++++------
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/dvdnav.c b/src/dvdnav.c
index 0f5db84..0c7fc0d 100644
--- a/src/dvdnav.c
+++ b/src/dvdnav.c
@@ -110,8 +110,7 @@ dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) {
   }
 
   /* Set the path. FIXME: Is a deep copy 'right' */
-  strncpy(this->path, path, MAX_PATH_LEN - 1);
-  this->path[MAX_PATH_LEN - 1] = '\0';
+  this->path = strdup(path);
 
   /* Pre-open and close a file so that the CSS-keys are cached. */
   this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS);
diff --git a/src/dvdnav_internal.h b/src/dvdnav_internal.h
index 0cb148e..1603ffe 100644
--- a/src/dvdnav_internal.h
+++ b/src/dvdnav_internal.h
@@ -68,13 +68,6 @@ static inline int _private_gettimeofday( struct timeval *tv, void *tz )
 /* Maximum length of an error string */
 #define MAX_ERR_LEN 255
 
-/* Use the POSIX PATH_MAX if available */
-#ifdef PATH_MAX
-#define MAX_PATH_LEN PATH_MAX
-#else
-#define MAX_PATH_LEN 255 /* Arbitrary */
-#endif
-
 #ifndef DVD_VIDEO_LB_LEN
 #define DVD_VIDEO_LB_LEN 2048
 #endif
@@ -139,7 +132,7 @@ typedef struct dvdnav_vobu_s {
 
 struct dvdnav_s {
   /* General data */
-  char        path[MAX_PATH_LEN]; /* Path to DVD device/dir */
+  char       *path;               /* Path to DVD device/dir */
   dvd_file_t *file;               /* Currently opened file */
 
   /* Position data */
diff --git a/src/remap.c b/src/remap.c
index 5601605..7a35f72 100644
--- a/src/remap.c
+++ b/src/remap.c
@@ -29,10 +29,6 @@
 #ifndef _MSC_VER
 #include <sys/param.h>
 #include <sys/fcntl.h>
-#else
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 255
-#endif
 #endif /* _MSC_VER */
 
 #include <inttypes.h>
@@ -193,7 +189,7 @@ static int parseblock(char *buf, int *dom, int *tt, int *pg,
 
 remap_t* remap_loadmap( char *title) {
     char buf[160];
-    char fname[MAXPATHLEN];
+    char *fname;
     char *home;
     int res;
     FILE *fp;
@@ -207,14 +203,19 @@ remap_t* remap_loadmap( char *title) {
         fprintf(MSG_OUT, "libdvdnav: Unable to find home directory" );
         return NULL;
     }
-    snprintf(fname, sizeof(fname), "%s/.dvdnav/%s.map", home, title);
+    fname = malloc(strlen("/.dvdnav/.map") + strlen(home) + strlen(title) + 1);
+    if (!fname)
+        return NULL;
+    sprintf(fname, "%s/.dvdnav/%s.map", home, title);
 
     /* Open the map file */
     fp = fopen( fname, "r");
     if (!fp) {
 	fprintf(MSG_OUT, "libdvdnav: Unable to find map file '%s'\n", fname);
+	free(fname);
 	return NULL;
     }
+    free(fname);
 
     /* Load the map file */
     map = remap_new( title);
-- 
1.7.5.4


Reply to: