Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Nov 2019 06:54:07 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354237 - head/stand/libsa
Message-ID:  <201911010654.xA16s760098377@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911010654.xA16s760098377>