Hey, when I publish the paper for %z*.s everyone on the Committee is gonna bother me about not having it implemented anywhere. Do you know any C libraries where they're not stiff-neck about extensions of this nature?
Conversation
Notices
-
Embed this notice
ThePhD (thephd@pony.social)'s status on Monday, 04-Dec-2023 07:18:16 JST ThePhD -
Embed this notice
ThePhD (thephd@pony.social)'s status on Monday, 04-Dec-2023 07:18:14 JST ThePhD @tthbaltazar Extension for printf to use size_t for the size of string printouts.
printf("%z*.s", my_str_size, my_str_ptr);Today, you can only have a size as big as INT_MAX, because printf's precision modifier for strings is spec'd to be int:
printf("%*.s", (int)my_str_size, my_str_ptr); // cast it or suffer ABI breakHaelwenn /элвэн/ :triskell: likes this. -
Embed this notice
Tóth Gábor Baltazár (tthbaltazar@chaos.social)'s status on Monday, 04-Dec-2023 07:18:15 JST Tóth Gábor Baltazár @thephd
what is %z*.s? -
Embed this notice
ThePhD (thephd@pony.social)'s status on Monday, 04-Dec-2023 07:19:06 JST ThePhD @tthbaltazar I (occasionally) work on large systems where we handle data that easily overflows a 4 byte integer. I would like to not accidentally have an overflow vulnerability in my printing routines.
-
Embed this notice
ThePhD (thephd@pony.social)'s status on Monday, 04-Dec-2023 07:19:06 JST ThePhD @tthbaltazar Not my wheelhouse entirely, but there's also systems with a 16-bit intand a 32-bit size_t. Which makes this problem infinitely worse.
Haelwenn /элвэн/ :triskell: likes this. -
Embed this notice
Tóth Gábor Baltazár (tthbaltazar@chaos.social)'s status on Monday, 04-Dec-2023 07:19:07 JST Tóth Gábor Baltazár @thephd
why are you printing strings longer than 2GB?
-
Embed this notice