Commit Graph

7 Commits

Author SHA1 Message Date
Karel Zak cc4b6a6570 lib/pty: minor cleanups
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-02-17 15:04:35 +08:00
наб f358fe6105 lib/pty: Put master PTY into non-blocking mode and buffer its output to avoid deadlock
If we filled the script->child buffer before the child had a chance to read any
input, we'd sleep forever in write_all(pty->master), and the child would sleep
forever in write(1<pty->slave>)

By putting the master PTY in non-blocking mode, we can poll(pty->master,
POLLOUT) and keep supplying more data as the child reads from the buffer

Fixes Debian bug #1003095

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-02-17 15:04:28 +08:00
Karel Zak 2dab772cba lib/procfs: add function to parse /proc/#/stat
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-02-17 15:01:19 +08:00
Petr Štetiar 6d8292f22a lib/path: ul_path_cpuparse: fix parsing of empty sysfs files
Kernel 5.15 returns empty content for topology/thread_siblings on
aarch64 platform, which in conjunction of uninitialized `buf` memory
buffer results in the garbage:

 (gdb) p buf
 $14 = " @\377\367\177\000\000\000\275\000\347j\032\236"

This garbage is then being later consumed by underlying helper functions
like for example cpumask_parse() and this leads to the following crash
later:

 in __libc_free (p=0x7ff7f67c00) at src/malloc/mallocng/free.c:105
 in free (p=<optimized out>) at src/malloc/free.c:5
 in add_cpuset_to_array (setsize=<optimized out>, set=<optimized out>, items=<optimized out>, ary=<optimized out>) at ../sys-utils/lscpu-topology.c:29
 in cputype_read_topology (cxt=cxt@entry=0x7ff7fffe70, ct=0x4298a0) at ../sys-utils/lscpu-topology.c:153
 in lscpu_read_topology (cxt=cxt@entry=0x7ff7fffe70) at ../sys-utils/lscpu-topology.c:629
 in main (argc=1, argv=0x7ffffffdb8) at ../sys-utils/lscpu.c:1341

It looks like the problem is that current logic expects fgets() to set
errno on failure, but fgets() is not documented to do so and and neither
glibc nor musl set errno.  So if errno was set to 0 before fgets() call,
the failure from fgets() is ignored and then invalid buffer is being
parsed.

Fixes: #1810
Suggested-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2023-02-17 14:59:32 +08:00
Chris Hofstaedtler 09b6184cdc Use sensible-pager
Closes: #1014368
2023-02-17 14:59:11 +08:00
su-fang e72d587bc0 merge upstream 2.38.1 2023-02-17 14:33:46 +08:00
openKylinBot fa45c7ac50 Import Upstream version 2.34 2022-05-14 03:14:32 +08:00