]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: Use 4K buffer size instead of BUFSIZ
authorKhem Raj <raj.khem@gmail.com>
Fri, 15 Sep 2023 07:18:18 +0000 (00:18 -0700)
committerKhem Raj <raj.khem@gmail.com>
Fri, 15 Sep 2023 22:38:59 +0000 (15:38 -0700)
Some lines in /proc/cpuinfo can be large e.g. flags and can then
truncate them in displaying them

BUFSIZ can vary quite a bit  e.g. glibc/linux systems its 8192
but on musl/linux and OSX its 1024, on mingW it is 256, some tests e.g.
x86_64-64cpu-linux6.2.tar.gz has added really long line for cpu flags
line which is greater than 1024 characters and hence this test fails
on musl because lscpu -s reports truncated string

Fixes x86_64-64cpu-linux6.2 tests

Signed-off-by: Khem Raj <raj.khem@gmail.com>
s

sys-utils/lscpu-cputype.c

index 3fd5f7a3c6d68ef765289367912acfffe039f3a8..c8f72ab8a112c25c6e43230d876c0ea8f2e13c27 100644 (file)
@@ -462,7 +462,9 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data)
 int lscpu_read_cpuinfo(struct lscpu_cxt *cxt)
 {
        FILE *fp;
-       char buf[BUFSIZ];
+       /* Used to be BUFSIZ which is small on some platforms e.g, musl,
+        * therefore hardcode to 4K */
+       char buf[4096];
        size_t i;
        struct lscpu_cputype *ct;
        struct cpuinfo_parser _pr = { .cxt = cxt }, *pr = &_pr;