Date: Wed, 26 Jan 2022 22:18:40 GMT From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 5a1a07f2a0e1 - main - sh: Don't add something to a null pointer Message-ID: <202201262218.20QMIe9H040960@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jilles: URL: https://cgit.FreeBSD.org/src/commit/?id=5a1a07f2a0e10179d38d8112fb5568e2b510b28c commit 5a1a07f2a0e10179d38d8112fb5568e2b510b28c Author: Jilles Tjoelker <jilles@FreeBSD.org> AuthorDate: 2022-01-23 21:15:57 +0000 Commit: Jilles Tjoelker <jilles@FreeBSD.org> CommitDate: 2022-01-26 22:13:20 +0000 sh: Don't add something to a null pointer Pointer arithmetic on a null pointer is undefined behavior. The bug can be reproduced by running bin/sh/tests/builtins/wait6.0 with UBSAN. Reported by: Mark Millard Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D34011 --- bin/sh/jobs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index c0ba7d75e16d..ff36bfa6d999 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -587,6 +587,8 @@ waitcmdloop(struct job *job) return retval; } } else { + if (njobs == 0) + return 0; for (jp = jobtab ; jp < jobtab + njobs; jp++) if (jp->used && jp->state == JOBDONE) { if (! iflag || ! jp->changed)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201262218.20QMIe9H040960>