summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-02-14 16:31:13 +1000
committerKeith Packard <keithp@keithp.com>2013-02-14 11:01:21 -0800
commit9a35d4240e2aa91ac104f0f9f86f83ff9a2d3d04 (patch)
tree5bb541b3108b9718cc1eee52d50aa0a0c012ea23 /os
parent955d434f4d755d00a24ae4068b9957765989d672 (diff)
os: fix pnprintf OOB buffer read for unterminated length modifiers
Format strings with length modifiers but missing format specifier like "%0" will read one byte past the array size. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os')
-rw-r--r--os/log.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/os/log.c b/os/log.c
index 2697acec8..95bd8cca9 100644
--- a/os/log.c
+++ b/os/log.c
@@ -304,6 +304,9 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9') || f[f_idx] == '.'))
f_idx++;
+ if (f_idx >= f_len)
+ break;
+
switch (f[f_idx]) {
case 's':
string_arg = va_arg(args, char*);