diff options
author | Christoph Berg <myon@debian.org> | 2017-01-04 10:53:51 -0800 |
---|---|---|
committer | Christoph Berg <myon@debian.org> | 2017-01-04 10:53:51 -0800 |
commit | dba594d7f4ce2f8a514751e8499a7d9ded6242fd (patch) | |
tree | 13665caf8c178b1352fad213c035cbd5ef05696c /src/main.c | |
parent | ee48f881b990ea2d29a709b023e9099e1ebef638 (diff) | |
parent | 61343128f5e7be31f1a09e81e76b8a683ce2434d (diff) |
Record flex (2.6.1-1.3) in archive suite sid
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -358,8 +358,8 @@ void check_options (void) 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 @@ void check_options (void) if (!endOfDir) endOfDir = path+length; - if ((endOfDir-path+2) >= sizeof(m4_path)) { - path = endOfDir+1; - continue; - } - - 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; + { + char m4_path[endOfDir-path + 1 + m4_length + 1]; + + 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]); |