[hackers] [ubase] ps: fix argv0 position in usage line || Mattias Andrée
commit 2d58716c23f946a84a941579ede6508f0b133361 Author: Mattias Andrée AuthorDate: Mon Jun 11 22:45:56 2018 +0200 Commit: sin CommitDate: Sat Jun 30 17:27:45 2018 +0100 ps: fix argv0 position in usage line Signed-off-by: Mattias Andrée diff --git a/ps.c b/ps.c index 114983b..00405a5 100644 --- a/ps.c +++ b/ps.c @@ -145,7 +145,7 @@ psr(const char *file) static void usage(void) { - eprintf("usage: [-aAdef] %s\n", argv0); + eprintf("usage: %s [-aAdef]\n", argv0); } int
[hackers] [ubase] mount: don't call realpath on root target || Ioan-Adrian Ratiu
commit 4f5837147a14e0fb8ec1a2a46a9c4045bdb75696 Author: Ioan-Adrian Ratiu AuthorDate: Sat Apr 7 05:33:30 2018 +0300 Commit: sin CommitDate: Sat Jun 30 17:38:07 2018 +0100 mount: don't call realpath on root target Musl libc realpath implementation calls readlink on a procfs path it computes via __procfdname (code at [1] & [2]). This is problematic if ubase mount is used in a PID 1 because procfs is not mounted and the kernel passes the rootfs mounted read-only, so the first step is to read-write remount the rootfs, which can't be done because procfs is not mounted. Thus we are in a dependency cycle: procfs can't be mounted because the root is read-only and so on. To break this cycle, don't call readlink on "/" (it doesn't really make sense anyway) so the rootfs can be remounted read-write, after which proc itself can be mounted and the rest of mount calls will succeed so systems running ubase + musl can succesfully boot into userspace. [1] https://git.musl-libc.org/cgit/musl/tree/src/misc/realpath.c?h=v1.1.19 [2] https://git.musl-libc.org/cgit/musl/tree/src/internal/procfdname.c?h=v1.1.19 Signed-off-by: Ioan-Adrian Ratiu diff --git a/mount.c b/mount.c index 4ce6680..e3d00b8 100644 --- a/mount.c +++ b/mount.c @@ -242,9 +242,11 @@ main(int argc, char *argv[]) if (!target) { target = argv[0]; source = NULL; - if (!(resolvpath = realpath(target, NULL))) - eprintf("realpath %s:", target); - target = resolvpath; + if (strcmp(target, "/") != 0) { + if (!(resolvpath = realpath(target, NULL))) + eprintf("realpath %s:", target); + target = resolvpath; + } } for (i = 0; files[i]; i++) {
[hackers] [ubase] Fix segfault in killall5 without -o || sin
commit 11d2d1faaf9cd0e2b6796c17390137dedcdc90bb Author: sin AuthorDate: Sat Jun 30 17:31:53 2018 +0100 Commit: sin CommitDate: Sat Jun 30 17:31:53 2018 +0100 Fix segfault in killall5 without -o Original patch by Platon Ryzhikov diff --git a/killall5.c b/killall5.c index 14790b9..f3541f5 100644 --- a/killall5.c +++ b/killall5.c @@ -73,10 +73,12 @@ main(int argc, char *argv[]) SLIST_INIT(_head); - for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) { - pe = emalloc(sizeof(*pe)); - pe->pid = estrtol(p, 10); - SLIST_INSERT_HEAD(_head, pe, entry); + if (oflag) { + for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) { + pe = emalloc(sizeof(*pe)); + pe->pid = estrtol(p, 10); + SLIST_INSERT_HEAD(_head, pe, entry); + } } if (sig != SIGSTOP && sig != SIGCONT)
[hackers] [st] Fix crash on resize || Jules Maselbas
commit 29f341da7cf32888f45005e08de202d9a372d972 Author: Jules Maselbas AuthorDate: Wed Jun 27 17:08:30 2018 +0200 Commit: Hiltjo Posthuma CommitDate: Sat Jun 30 20:51:46 2018 +0200 Fix crash on resize Prevent to realloc xw.specbuc with a negative number of col. Add proper hints for the minimal size, for one character. diff --git a/x.c b/x.c index c0bd890..00cb6b1 100644 --- a/x.c +++ b/x.c @@ -672,6 +672,8 @@ cresize(int width, int height) col = (win.w - 2 * borderpx) / win.cw; row = (win.h - 2 * borderpx) / win.ch; + col = MAX(1, col); + row = MAX(1, row); tresize(col, row); xresize(col, row); @@ -681,8 +683,8 @@ cresize(int width, int height) void xresize(int col, int row) { - win.tw = MAX(1, col * win.cw); - win.th = MAX(1, row * win.ch); + win.tw = col * win.cw; + win.th = row * win.ch; XFreePixmap(xw.dpy, xw.buf); xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, @@ -788,15 +790,17 @@ xhints(void) sizeh = XAllocSizeHints(); - sizeh->flags = PSize | PResizeInc | PBaseSize; + sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; sizeh->height = win.h; sizeh->width = win.w; sizeh->height_inc = win.ch; sizeh->width_inc = win.cw; sizeh->base_height = 2 * borderpx; sizeh->base_width = 2 * borderpx; + sizeh->min_height = win.ch + 2 * borderpx; + sizeh->min_width = win.cw + 2 * borderpx; if (xw.isfixed) { - sizeh->flags |= PMaxSize | PMinSize; + sizeh->flags |= PMaxSize; sizeh->min_width = sizeh->max_width = win.w; sizeh->min_height = sizeh->max_height = win.h; }