svn commit: r354330 - stable/12/stand/libsa

Toomas Soome tsoome at FreeBSD.org
Mon Nov 4 06:35:49 UTC 2019


Author: tsoome
Date: Mon Nov  4 06:35:48 2019
New Revision: 354330
URL: https://svnweb.freebsd.org/changeset/base/354330

Log:
  MFC r354237:
  loader: asprinf does crash arm64 due to missing NULL pointer check
  
  PCHAR macro needs to check if d is NULL.

Modified:
  stable/12/stand/libsa/printf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/libsa/printf.c
==============================================================================
--- stable/12/stand/libsa/printf.c	Mon Nov  4 06:16:00 2019	(r354329)
+++ stable/12/stand/libsa/printf.c	Mon Nov  4 06:35:48 2019	(r354330)
@@ -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-stable mailing list