summaryrefslogtreecommitdiff
path: root/common/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/printf.c')
-rw-r--r--common/printf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/printf.c b/common/printf.c
index 1f6733e552..dd66d3630a 100644
--- a/common/printf.c
+++ b/common/printf.c
@@ -225,7 +225,7 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context,
/*
* Handle length:
- * %l - long
+ * %l - DEPRECATED (see below)
* %ll - long long
* %z - size_t
*/
@@ -239,6 +239,22 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context,
c = *format++;
}
+ /*
+ * %l on 32-bit systems is deliberately
+ * deprecated. It was originally used as
+ * shorthand for 64-bit values. When
+ * compile-time printf format checking was
+ * enabled, it had to be cleaned up to be
+ * sizeof(long), which is 32 bits on today's
+ * ECs. This presents a mismatch which can be
+ * dangerous if a new-style printf call is
+ * cherry-picked into an old firmware branch.
+ * See crbug.com/984041 for more context.
+ */
+ if (!(flags & PF_64BIT)) {
+ format = error_str;
+ continue;
+ }
} else if (c == 'z') {
if (sizeof(size_t) == sizeof(uint64_t))
flags |= PF_64BIT;