summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-31 21:19:25 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-31 21:19:25 -0500
commit793dc7764c5ae619c476646ca5e3bfa5e5f150d5 (patch)
tree3557c19c872416774ba135b2c5d88afbdffed797
parent1e85d81f5b4773275471fe7bbc707e8d64fb0a08 (diff)
UB on invalid lengths
-rw-r--r--src/stdio/__printf.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c
index db34e288..14170099 100644
--- a/src/stdio/__printf.c
+++ b/src/stdio/__printf.c
@@ -205,9 +205,25 @@ int (__printf)(struct io_options *opt, const char * format, va_list arg)
}
if ((flags & ALT) && (!strchr("xXaAeEfFgG", format[i]))) {
- __undefined("In call to %s(): The # flag is undefined for %%%c", opt->fnname, format[i]);
+ __undefined("In call to %s(): The '#' flag is undefined for %%%c", opt->fnname, format[i]);
} else if ((flags & ZERO) && (!strchr("diouxXaAeEfFgG", format[i]))) {
- __undefined("In call to %s(): The 0 flag is undefined for %%%c", opt->fnname, format[i]);
+ __undefined("In call to %s(): The '0' flag is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == hh) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 'hh' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == h) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 'h' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == l) && (!strchr("diouxXncsaAeEfFgG", format[i]))) {
+ __undefined("In call to %s(): The length 'l' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == ll) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 'll' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == j) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 'j' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == z) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 'z' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == t) && (!strchr("diouxXn", format[i]))) {
+ __undefined("In call to %s(): The length 't' is undefined for %%%c", opt->fnname, format[i]);
+ } else if ((length == L) && (!strchr("aAeEfFgG", format[i]))) {
+ __undefined("In call to %s(): The length 'L' is undefined for %%%c", opt->fnname, format[i]);
}
switch (format[i]) {