From: Eugene Syromiatnikov Date: Thu, 14 Aug 2025 17:04:32 +0000 (+0200) Subject: crypto/bio/bio_print.c: add 't' (ptrdiff_t) length modifier X-Git-Tag: openssl-3.6.0-alpha1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=779346f2ec5ff86be47f3ebf01ab9eaa20d5e0b6;p=thirdparty%2Fopenssl.git crypto/bio/bio_print.c: add 't' (ptrdiff_t) length modifier As specified by POSIX.1-2001 and C99. Signed-off-by: Eugene Syromiatnikov Reviewed-by: Saša Nedvědický Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28177) --- diff --git a/crypto/bio/bio_print.c b/crypto/bio/bio_print.c index d08b37370fa..f8031743ac1 100644 --- a/crypto/bio/bio_print.c +++ b/crypto/bio/bio_print.c @@ -74,6 +74,7 @@ static int _dopr(char **sbuffer, char **buffer, #define DP_C_LDOUBLE 4 #define DP_C_LLONG 5 #define DP_C_SIZE 6 +#define DP_C_PTRDIFF 7 /* Floating point formats */ #define F_FORMAT 0 @@ -216,6 +217,10 @@ _dopr(char **sbuffer, cflags = DP_C_SIZE; ch = *format++; break; + case 't': + cflags = DP_C_PTRDIFF; + ch = *format++; + break; default: break; } @@ -241,6 +246,9 @@ _dopr(char **sbuffer, case DP_C_SIZE: value = va_arg(args, ossl_ssize_t); break; + case DP_C_PTRDIFF: + value = va_arg(args, ptrdiff_t); + break; default: value = va_arg(args, int); break; @@ -272,6 +280,17 @@ _dopr(char **sbuffer, case DP_C_SIZE: value = va_arg(args, size_t); break; + case DP_C_PTRDIFF: + /* + * There is no unsigned variant of ptrdiff_t, and POSIX + * requires using a "corresponding unsigned type argument". + * Assuming it is power of two in size, at least. + */ + if (sizeof(ptrdiff_t) == sizeof(uint64_t)) + value = va_arg(args, uint64_t); + else + value = va_arg(args, unsigned int); + break; default: value = va_arg(args, unsigned int); break;