Still Failing: g-i-installation_debian_sid_daily_hurd_lxde/336

2017-04-05 Thread jenkins
See 
https://jenkins.debian.net/job/g-i-installation_debian_sid_daily_hurd_lxde/336/ 
and 
https://jenkins.debian.net/job/g-i-installation_debian_sid_daily_hurd_lxde/336//console
 and 
https://jenkins.debian.net/job/g-i-installation_debian_sid_daily_hurd_lxde/336//artifact/results/
 if there are any.

Re: gputils: FTBFS on hurd-i386 (for review)

2017-04-05 Thread Svante Signell
On Tue, 2017-04-04 at 02:25 +0200, Guillem Jover wrote:
> Hi!
> 
> On Fri, 2017-03-31 at 15:13:03 +0200, Svante Signell wrote:
> > Source: gputils
> > Version: 1.4.0-0.1
> > Severity: important
> > Tags: patch
> > User: debian-hurd@lists.debian.org
> > Usertags: hurd
> > gputils currently FTBFS on GNU/Hurd due to PATH_MAX not being defined. The
> > attached patch fixes this issue by allocating strings dynamically and remove
> > them when not needed any more.

Gullem,

Thank you for the review. Attached is an updated patch. Is it OK now? I still
have to check return values of snprintf and realloc and maybe also switch to
using alloca (not POSIX though).Index: gputils-1.4.0/gplink/gplink.c
===
--- gputils-1.4.0.orig/gplink/gplink.c
+++ gputils-1.4.0/gplink/gplink.c
@@ -321,17 +321,23 @@ gplink_open_coff(const char *name)
   gp_object_type *object;
   gp_archive_type *archive;
   FILE *coff;
-  char file_name[PATH_MAX + 1];
-
-  strncpy(file_name, name, sizeof(file_name));
+  char *file_name = NULL;
+  int len = 0;
 
+  file_name = strdup(name);
+  if (file_name == NULL) {
+perror(name);
+exit(1);
+  }
   coff = fopen(file_name, "rb");
   if ((coff == NULL) && (strchr(file_name, PATH_CHAR) == 0)) {
 /* If no "/" in name, try searching include pathes. */
 int i;
 
 for (i = 0; i < state.numpaths; i++) {
-  snprintf(file_name, sizeof(file_name), "%s" COPY_CHAR "%s", state.paths[i], name);
+  len = snprintf(NULL, 0, "%s" COPY_CHAR "%s", state.paths[i], name) + 1;
+  file_name = realloc(file_name, len);
+  snprintf(file_name, len, "%s" COPY_CHAR "%s", state.paths[i], name);
   coff = fopen(file_name, "rb");
 
   if (coff != NULL) {
@@ -341,6 +347,8 @@ gplink_open_coff(const char *name)
   }
 
   if (coff == NULL) {
+if (file_name)
+  free(file_name);
 perror(name);
 exit(1);
   }
@@ -368,6 +376,8 @@ gplink_open_coff(const char *name)
   default:
 assert(0);
   }
+  if(file_name)
+free(file_name);
 }
 
 static void
Index: gputils-1.4.0/gplink/lst.c
===
--- gputils-1.4.0.orig/gplink/lst.c
+++ gputils-1.4.0/gplink/lst.c
@@ -35,9 +35,9 @@ static gp_section_type *line_section;
 static void
 open_src(const char *name, gp_symbol_type *symbol)
 {
-  char file_name[PATH_MAX + 1];
+  char *file_name = NULL;
   struct list_context *new = malloc(sizeof(*new));
-  int i;
+  int i, len;
 
   assert(name != NULL);
 
@@ -45,20 +45,28 @@ open_src(const char *name, gp_symbol_typ
   if (new->f == NULL) {
 /* Try searching include pathes */
 for (i = 0; i < state.numpaths; i++) {
-  snprintf(file_name, sizeof(file_name), "%s" COPY_CHAR "%s", state.paths[i], name);
+  len = snprintf(NULL, 0, "%s" COPY_CHAR "%s", state.paths[i], name) + 1;
+  file_name = realloc(file_name, len);
+  snprintf(file_name, len, "%s" COPY_CHAR "%s", state.paths[i], name);
   new->f = fopen(file_name, "rb");
   if (new->f != NULL) {
 name = file_name;
 break;
   }
 }
+if(file_name)
+  free(file_name);
+
 if (new->f == NULL) {
   /* The path may belong to a build procedure other than this */
   const char *p = strrchr(name, PATH_CHAR);
 
   if (p != NULL) {
+file_name = NULL;
 for (i = 0; i < state.numpaths; i++) {
-  snprintf(file_name, sizeof(file_name), "%s%s", state.paths[i], p);
+  len = snprintf(NULL, 0, "%s%s", state.paths[i], p) + 1;
+  file_name = realloc(file_name, len);
+  snprintf(file_name, len, "%s%s", state.paths[i], p);
   new->f = fopen(file_name, "rb");
   if (new->f != NULL) {
 name = file_name;
@@ -67,6 +75,8 @@ open_src(const char *name, gp_symbol_typ
 }
   }
 }
+if(file_name)
+  free(file_name);
   }
 
   if (new->f != NULL) {
Index: gputils-1.4.0/gpasm/scan.l
===
--- gputils-1.4.0.orig/gpasm/scan.l
+++ gputils-1.4.0/gpasm/scan.l
@@ -626,12 +626,13 @@ a'{STR_QCHAR}'   {
 static void
 search_paths(struct source_context *new, const char *name)
 {
-  char tryname[PATH_MAX + 1];
-  int i;
+  char *tryname = NULL;
+  int i, len;
 
   for (i = 0; i < state.path_num; i++) {
-snprintf(tryname, sizeof(tryname),
- "%s" COPY_CHAR "%s", state.paths[i], name);
+len = snprintf(NULL, 0, "%s" COPY_CHAR "%s", state.paths[i], name) + 1;
+tryname = realloc(tryname, len);
+snprintf(tryname, len, "%s" COPY_CHAR "%s", state.paths[i], name);
 new->f = fopen(tryname, "rt");
 
 if (new->f != NULL) {
@@ -639,6 +640,8 @@ search_paths(struct source_context *new,
   break;
 }
   }
+  if (tryname)
+free(tryname);
 }
 
 void