Live data from Hacker News

Best of show – abuse of libc

ioccc.org

11–20 of 84 posts

Re: Best of show – abuse of libc

#12
post #5

> Format specifiers can take extra “arguments”. - "%hhn": store the number of bytes written mod 256 to the char pointer ... Oh boy. I'll put that down for my "thing I don't think I wanted to know" of the day.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

GNU's printf specifier language is Turing complete, I believe.

Re: Best of show – abuse of libc

#13

Earlier quoted context omitted.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

GNU's printf specifier language is Turing complete, I believe.

Theres a great example of what you can do with this, submitted and discussed on HN here: https://news.ycombinator.com/item?id=25690319

Re: Best of show – abuse of libc

#14
post #9

Up next: a C compiler that compiles to printf statements :-P

https://github.com/HexHive/printbf well this is a brainfuck interpreter inside printf. I’m pretty sure there are plenty of c-to-bf transpilers.

This is by the same author as the ioccc entry and also one of authors of the paper showing the turing completeness of printf http://nebelwelt.net/publications/#15SEC

Re: Best of show – abuse of libc

#15
post #5

> Format specifiers can take extra “arguments”. - "%hhn": store the number of bytes written mod 256 to the char pointer ... Oh boy. I'll put that down for my "thing I don't think I wanted to know" of the day.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

So I can port doom to gnu printf?

Re: Best of show – abuse of libc

#16
post #9

Up next: a C compiler that compiles to printf statements :-P

https://github.com/HexHive/printbf well this is a brainfuck interpreter inside printf. I’m pretty sure there are plenty of c-to-bf transpilers.

That's fun, but esoteric languages in general and brainfuck in specific tend to lack things you'd want out of c: file system access, system calls, etc.

Re: Best of show – abuse of libc

#17

Earlier quoted context omitted.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

So I can port doom to gnu printf?

GNU's printf is Turing complete[0]... so "yes."

[0] Mentioned (but not directly linked) by TFA:

https://www.usenix.org/conference/usenixsecurity15/technical...

Re: Best of show – abuse of libc

#18
post #10

How did printf end up here in the first place? Decades of feature additions, or were these features a part of an early spec?

%n was defined in C89, the first C standard: http://port70.net/~nsz/c/c89/c89-draft.html#4.9.6.1

Looking at old source code, the earliest implementation I found is 4.3BSD Tahoe (1988). See https://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/... Second oldest I found was Tenth Edition [Research] Unix (1989). See ocvt_n at https://www.tuhs.org/cgi-bin/utree.pl?file=V10/libc/stdio/vf... I couldn't find support in earlier implementations archived on that site.

Re: Best of show – abuse of libc

#20
post #2

General thread here: https://news.ycombinator.com/item?id=25651942

Personally I find it amusing that the 0-signal comment "Thanks for all dang" is upvoted while the opposite 0-signal comment "Thanks for nothing dang" is downvoted. I mean, I think dang is chill, but neither of these really contributes to the discussion any more than the other, so shouldn't they have the same score? Upvotes really are a popularity contest these days.
Post reply on HN