Package: flex
Version: 2.6.1-1
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd

Hello,

flex currently FTBFS on hurd-i386 because it unconditionnally uses
PATH_MAX. The attached patch makes it just dynamically allocate the
proper buffer size.

Actually flax even bogusly used PATH_MAX, since it checked for "path"
being not too long, but didn't take into account the additional length
of "m4", so the proposed patch is actually a bugfix on !hurd too: if
PATH contains a path with more than PATH_MAX characters, the additional
"m4" two bytes were overflowing the m4_path array.

Samuel

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 
'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 
'experimental-debug'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages flex depends on:
ii  cdebconf [debconf-2.0]  0.215
ii  debconf [debconf-2.0]   1.5.59
ii  dpkg                    1.18.10
ii  install-info            6.3.0.dfsg.1-1
ii  libc6                   2.23-5
ii  libfl-dev               2.6.1-1
ii  m4                      1.4.17-5

Versions of packages flex recommends:
ii  clang-3.5 [c-compiler]  1:3.5.2-3
ii  clang-3.6 [c-compiler]  1:3.6.2-3
ii  gcc [c-compiler]        4:6.1.1-1
ii  gcc-5 [c-compiler]      5.4.1-1
ii  gcc-6 [c-compiler]      6.1.1-11

Versions of packages flex suggests:
ii  bison            2:3.0.4.dfsg-1
ii  build-essential  12.2

-- no debconf information

-- 
Samuel
"I don't know why, but first C programs tend to look a lot worse than
first programs in any other language (maybe except for fortran, but then
I suspect all fortran programs look like `firsts')"
(By Olaf Kirch)
--- src/main.c.original 2016-09-17 15:05:32.000000000 +0000
+++ src/main.c  2016-09-17 15:13:47.000000000 +0000
@@ -358,8 +358,8 @@
                        if (!path) {
                                m4 = M4;
                        } else {
+                               int m4_length = strlen(m4);
                                do {
-                                       char m4_path[PATH_MAX];
                                        int length = strlen(path);
                                        struct stat sbuf;
 
@@ -367,19 +367,17 @@
                                        if (!endOfDir)
                                                endOfDir = path+length;
 
-                                       if ((endOfDir-path+2) >= 
sizeof(m4_path)) {
-                                           path = endOfDir+1;
-                                               continue;
-                                       }
+                                       {
+                                               char m4_path[endOfDir-path + 1 
+ m4_length + 1];
 
-                                       strncpy(m4_path, path, sizeof(m4_path));
-                                       m4_path[endOfDir-path] = '/';
-                                       m4_path[endOfDir-path+1] = '\0';
-                                       strncat(m4_path, m4, sizeof(m4_path));
-                                       if (stat(m4_path, &sbuf) == 0 &&
-                                               (S_ISREG(sbuf.st_mode)) && 
sbuf.st_mode & S_IXUSR) {
-                                               m4 = strdup(m4_path);
-                                               break;
+                                               memcpy(m4_path, path, 
endOfDir-path);
+                                               m4_path[endOfDir-path] = '/';
+                                               memcpy(m4_path + 
(endOfDir-path) + 1, m4, m4_length + 1);
+                                               if (stat(m4_path, &sbuf) == 0 &&
+                                                       (S_ISREG(sbuf.st_mode)) 
&& sbuf.st_mode & S_IXUSR) {
+                                                       m4 = strdup(m4_path);
+                                                       break;
+                                               }
                                        }
                                        path = endOfDir+1;
                                } while (path[0]);

Reply via email to