3 ms·
That's frightening. Is there any legit use case for this in the real world that would stop, e.g., glibc from removing it altogether?
by lewiscollard 6y ago
That's frightening. Is there any legit use case for this in the real world that would stop, e.g., glibc from removing it altogether?
- saagarjha 6y agoSome programs use it for formatting purposes. macOS enabled “no format strings from writable memory” a while back and it broke these.
- projektfu 6y agoPerhaps you could print non-tabulated numbers until you run close to the end of line and be counting the characters with %n. Then you can print a new line, set your counter to zero, and continue.
- nitrogen 6y agoYou might want to know where in the output string different elements of your format string were placed. I've used %n with sscanf, but not *printf.
- projektfu 6y agoI got curious and looked through sources. I'm not sure where it was added, but it appeared between 4.3BSD and the 4.3BSD Tahoe edition according to the man pages. It did not seem to be present in System III. Searching for actual uses, I didn't find any that weren't testing the functionality (unit tests) or hacking the stack.