For some reason, it has been removed in commit
15b337fa58ba "bio/b_print.c:
switch to int64_t as "greatest-width integer type".", despite being a part
of the standard in both ANSI C and POSIX.1-2001. Bring it back for all
the supported length modifiers.
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)
break;
case 's':
strvalue = va_arg(args, char *);
- if (max < 0) {
- if (buffer || *maxlen > INT_MAX)
- max = INT_MAX;
- else
- max = (int)*maxlen;
- }
+ if (max < 0)
+ max = INT_MAX;
if (!fmtstr(&desc, strvalue, flags, min, max))
goto out;
break;
goto out;
break;
case 'n':
- *num = (int)desc.pos;
+ switch (cflags) {
+#define HANDLE_N(type) \
+ do { \
+ type *num; \
+ \
+ num = va_arg(args, type *); \
+ *num = (type) desc.pos; \
+ } while (0)
+ case DP_C_CHAR:
+ HANDLE_N(signed char);
+ break;
+ case DP_C_SHORT:
+ HANDLE_N(short);
+ break;
+ case DP_C_LONG:
+ HANDLE_N(long);
+ break;
+ case DP_C_LLONG:
+ HANDLE_N(long long);
+ break;
+ case DP_C_SIZE:
+ HANDLE_N(ossl_ssize_t);
+ break;
+ case DP_C_PTRDIFF:
+ HANDLE_N(ptrdiff_t);
+ break;
+ default:
+ HANDLE_N(int);
+ break;
+#undef HANDLE_N
}
break;
case '%':