svn commit: r354237 - head/stand/libsa

Toomas Soome tsoome at FreeBSD.org
Fri Nov 1 06:54:08 UTC 2019


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;


More information about the svn-src-all mailing list