lm-sensors: FTBFS on hurd-i386 (for review)
Source: lm-sensors
Version: 3.4.0-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd
Hello,
Currently lm-sensors fails to build on GNU/Hurd due to PAH_MAX issues,
see [1]. The attached patch 15-PATH_MAX.patch solves this by allocating
the strings 'path' in lib/init.c and 'buf' in lib/access.c dynamically
and free them if needed.
Additionally the dependency on librrd2-dev should be changed to
librrd-dev, see debian_control.patch, since the latest version of
rrdtool 1.5.4-5 no longer provides this library. (packages ntop and
ganglia also have this dependency and should be modified too)
[1] https://buildd.debian.org/status/fetch.php?pkg=lm-sensors
&arch=hurd-i386&ver=1%3A3.4.0-1&stamp=1439202330
Thanks!
--- a/debian/control 2015-08-09 11:30:18.000000000 +0200
+++ b/debian/control 2015-08-25 11:45:13.000000000 +0200
@@ -1,7 +1,7 @@
Source: lm-sensors
Section: utils
Priority: extra
-Build-Depends: debhelper (>= 8.1.3), bison, flex, librrd2-dev, dh-systemd (>= 1.3)
+Build-Depends: debhelper (>= 8.1.3), bison, flex, librrd-dev, dh-systemd (>= 1.3)
Maintainer: Aurelien Jarno <aurel32@debian.org>
Standards-Version: 3.9.6
Homepage: http://www.lm-sensors.org
Index: lm-sensors-3.4.0/lib/init.c
===================================================================
--- lm-sensors-3.4.0.orig/lib/init.c
+++ lm-sensors-3.4.0/lib/init.c
@@ -141,21 +141,25 @@ static int add_config_from_dir(const cha
}
for (res = 0, i = 0; !res && i < count; i++) {
- int len;
- char path[PATH_MAX];
+ int len, path_len;
+ char *path = NULL;
FILE *input;
struct stat st;
-
- len = snprintf(path, sizeof(path), "%s/%s", dir,
+
+ path_len = strlen(dir) + 1 + strlen(namelist[i]->d_name) + 1;
+ path = malloc(path_len);
+ len = snprintf(path, path_len, "%s/%s", dir,
namelist[i]->d_name);
- if (len < 0 || len >= (int)sizeof(path)) {
+ if (len != path_len - 1) {
res = -SENSORS_ERR_PARSE;
continue;
}
/* Only accept regular files */
- if (stat(path, &st) < 0 || !S_ISREG(st.st_mode))
- continue;
+ if (stat(path, &st) < 0 || !S_ISREG(st.st_mode)) {
+ free(path);
+ continue;
+ }
input = fopen(path, "r");
if (input) {
@@ -165,6 +169,7 @@ static int add_config_from_dir(const cha
res = -SENSORS_ERR_PARSE;
sensors_parse_error_wfn(strerror(errno), path, 0);
}
+ free(path);
}
/* Free memory allocated by scandir() */
Index: lm-sensors-3.4.0/lib/access.c
===================================================================
--- lm-sensors-3.4.0.orig/lib/access.c
+++ lm-sensors-3.4.0/lib/access.c
@@ -168,9 +168,9 @@ char *sensors_get_label(const sensors_ch
{
char *label;
const sensors_chip *chip;
- char buf[PATH_MAX];
+ char *buf = NULL;
FILE *f;
- int i;
+ int i, len;
if (sensors_chip_name_has_wildcards(name))
return NULL;
@@ -183,10 +183,12 @@ char *sensors_get_label(const sensors_ch
}
/* No user specified label, check for a _label sysfs file */
- snprintf(buf, PATH_MAX, "%s/%s_label", name->path, feature->name);
+ len = strlen(name->path) + 1 + strlen(feature->name) + 6 + 1;
+ buf = malloc(len);
+ snprintf(buf, len, "%s/%s_label", name->path, feature->name);
if ((f = fopen(buf, "r"))) {
- i = fread(buf, 1, sizeof(buf), f);
+ i = fread(buf, 1, len, f);
fclose(f);
if (i > 0) {
/* i - 1 to strip the '\n' at the end */
@@ -197,10 +199,9 @@ char *sensors_get_label(const sensors_ch
}
/* No label, return the feature name instead */
- label = feature->name;
+ label = strdup(feature->name);
sensors_get_label_exit:
- label = strdup(label);
if (!label)
sensors_fatal_error(__func__, "Allocating label text");
return label;
Reply to: