stdio: fix %N.Ms miscalculating spacing if M > strlen(arg)

This commit is contained in:
Lephenixnoir 2024-02-04 20:13:25 +01:00
parent 05ff5e246d
commit 46c73cbc87
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -59,6 +59,8 @@ void __printf_format_s(
size_t len = 0;
uint32_t precision = opt->precision ? opt->precision : (-1);
while(s[len] && len < precision) len++;
/* Cap precision to real value for __printf_compute_geometry() */
opt->precision = len;
struct __printf_geometry g = {
.prefix = 0, .sign = 0, .content = len,