diff options
-rw-r--r-- | METADATA | 4 | ||||
-rw-r--r-- | toys/other/oneit.c | 15 | ||||
-rw-r--r-- | toys/other/vmstat.c | 2 |
3 files changed, 11 insertions, 10 deletions
@@ -13,11 +13,11 @@ third_party { type: GIT value: "https://github.com/landley/toybox" } - version: "c8f758c734506d6131c2eefdb5ce2618d4b2b1d2" + version: "8626a6ac7dff93bf97f754c93c3e426ee5c6b1e0" license_type: UNENCUMBERED last_upgrade_date { year: 2023 month: 4 - day: 14 + day: 17 } } diff --git a/toys/other/oneit.c b/toys/other/oneit.c index d154f582..c0b0c09d 100644 --- a/toys/other/oneit.c +++ b/toys/other/oneit.c @@ -72,14 +72,15 @@ void oneit_main(void) // Autodetect console from sysfs if no -c memcpy(toybuf, "/dev/", 5); - if (!TT.c && (TT.c = readfile("/sys/class/tty/console/active", ss, 4096))) { - // Remove null terminator, take last entry - for (;;) { - if (!(ss = strchr(TT.c, '\n'))) break; - if (!ss[1]) *ss = 0; - else TT.c = ++ss; + i = sizeof(toybuf)-6; + if (!TT.c && (TT.c = readfile("/sys/class/tty/console/active", ss, i))) { + // Take last entry, remove newline terminator + while (TT.c[i = strcspn(TT.c, " \n")]) { + TT.c[i++] = 0; + if (TT.c[i]) TT.c += i; + else break; } - // Ensure /dev prefix + // Ensure exactly one /dev prefix strstart(&TT.c, "/dev/"); memmove(toybuf+5, TT.c, strlen(TT.c)); TT.c = toybuf; diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c index ebe5399e..94502f1f 100644 --- a/toys/other/vmstat.c +++ b/toys/other/vmstat.c @@ -49,7 +49,7 @@ static void get_vmstat_proc(struct vmstat_proc *vmsp) "Buffers:", "Cached:", "SwapFree:", "SwapTotal:", "SReclaimable:", "/proc/vmstat", "pgpgin ", "pgpgout ", "pswpin ", "pswpout " }; unsigned long long *new = (void *)vmsp; - char *p, *name = name, *file = 0; + char *p = 0, *name = name, *file = 0; int i, j; // We use vmstuff to fill out vmstat_proc as an array of long long: |