Per [1]:
hh
Specifies that a following d, i, o, u, x, or X conversion specifier
applies to a signed char or unsigned char argument
[1] https://pubs.opengroup.org/onlinepubs/
9799919799//functions/printf.html
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28177)
#define DP_F_UNSIGNED (1 << 6)
/* conversion flags */
-#define DP_C_SHORT 1
-#define DP_C_LONG 2
-#define DP_C_LDOUBLE 3
-#define DP_C_LLONG 4
-#define DP_C_SIZE 5
+#define DP_C_CHAR 1
+#define DP_C_SHORT 2
+#define DP_C_LONG 3
+#define DP_C_LDOUBLE 4
+#define DP_C_LLONG 5
+#define DP_C_SIZE 6
/* Floating point formats */
#define F_FORMAT 0
case DP_S_MOD:
switch (ch) {
case 'h':
- cflags = DP_C_SHORT;
+ if (*format == 'h') {
+ cflags = DP_C_CHAR;
+ format++;
+ } else {
+ cflags = DP_C_SHORT;
+ }
ch = *format++;
break;
case 'l':
case 'd':
case 'i':
switch (cflags) {
+ case DP_C_CHAR:
+ value = (signed char)va_arg(args, int);
+ break;
case DP_C_SHORT:
value = (short int)va_arg(args, int);
break;
case 'u':
flags |= DP_F_UNSIGNED;
switch (cflags) {
+ case DP_C_CHAR:
+ value = (unsigned char)va_arg(args, unsigned int);
+ break;
case DP_C_SHORT:
value = (unsigned short int)va_arg(args, unsigned int);
break;