From owner-svn-src-head@freebsd.org Fri Nov 1 06:54:08 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 307CD1AACE6; Fri, 1 Nov 2019 06:54:08 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 474CbN0GTMz3MkT; Fri, 1 Nov 2019 06:54:08 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E085E74FC; Fri, 1 Nov 2019 06:54:07 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA16s7JG098378; Fri, 1 Nov 2019 06:54:07 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA16s760098377; Fri, 1 Nov 2019 06:54:07 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911010654.xA16s760098377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Fri, 1 Nov 2019 06:54:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354237 - head/stand/libsa X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/libsa X-SVN-Commit-Revision: 354237 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Nov 2019 06:54:08 -0000 Author: tsoome Date: Fri Nov 1 06:54:07 2019 New Revision: 354237 URL: https://svnweb.freebsd.org/changeset/base/354237 Log: loader: asprinf does crash arm64 due to missing NULL pointer check PCHAR macro needs to check if d is NULL. MFC after: 3 days Modified: head/stand/libsa/printf.c Modified: head/stand/libsa/printf.c ============================================================================== --- head/stand/libsa/printf.c Fri Nov 1 03:10:53 2019 (r354236) +++ head/stand/libsa/printf.c Fri Nov 1 06:54:07 2019 (r354237) @@ -247,7 +247,17 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *len static int kvprintf(char const *fmt, kvprintf_fn_t *func, void *arg, int radix, va_list ap) { -#define PCHAR(c) {int cc=(c); if (func) (*func)(cc, arg); else *d++ = cc; retval++; } +#define PCHAR(c) { \ + int cc = (c); \ + \ + if (func) { \ + (*func)(cc, arg); \ + } else if (d != NULL) { \ + *d++ = cc; \ + } \ + retval++; \ + } + char nbuf[MAXNBUF]; char *d; const char *p, *percent, *q;