Earlier quoted context omitted.
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.
Hm, I think you could add numeric syscalls, similar to what happens at the asm level. E.g. put the syscall id and some parameters on the "stack", then let the interpreter run the syscall with a new "instruction" e.g. '!'. This could even substitute '.' (putchar) and ',' (getchar), since these are very much just syscalls. So that would reduce the number of instructions by one (to 7). Oh, getting to 6 would also be fun…
Best of show – abuse of libc
31–40 of 84 posts
Re: Best of show – abuse of libc
#32General 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.
Empty comments can be ok if they're positive. There's nothing wrong with submitting a comment saying just "Thanks." What we especially discourage are comments that are empty and negative—comments that are mere name-calling.
If you think in terms of what's good/bad for community it may make more sense.
(I hope it's clear this applies whether or not the mods were mentioned in either a positive or negative way.)
Re: Best of show – abuse of libc
#33Re: Best of show – abuse of libc
#34Earlier quoted context omitted.
Another interesting factoid is that macOS only supports %n if the format string is located in read-only memory. Per printf(3) on macOS: > For this reason, a format argument containing %n is assumed to be untrustworthy if located in writable memory (i.e. memory with protection PROT_WRITE; see mprotect(2)) and any attempt to use such an argument is fatal. Practically, this means that %n is permitted in literal format s…
Someone should inform The Open Group about this violation of POSIX ;) Another fun fact: glibc does this too, if you compile with -D_FORTIFY_SOURCE=2. However, since Linux lacks the nice vm_region APIs the code opens up /proc/self/maps :/
Re: Best of show – abuse of libc
#35For those interested in more Turing complete format strings, look no further than the "sprint" challenge from this year's Google CTF Quals: https://ctftime.org/task/12834 . It's sprintf in a loop this time and the program simulates a maze: https://github.com/google/google-ctf/tree/master/2020/quals/...
Re: Best of show – abuse of libc
#36Earlier quoted context omitted.
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
#37It’s actually intentionally disallowed in some libc implementations.
Re: Best of show – abuse of libc
#38Earlier quoted context omitted.
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.
Hm, I think you could add numeric syscalls, similar to what happens at the asm level. E.g. put the syscall id and some parameters on the "stack", then let the interpreter run the syscall with a new "instruction" e.g. '!'. This could even substitute '.' (putchar) and ',' (getchar), since these are very much just syscalls. So that would reduce the number of instructions by one (to 7). Oh, getting to 6 would also be fun…
Re: Best of show – abuse of libc
#39Up next: a C compiler that compiles to printf statements :-P
I feel like it did LLVM IR to a bunch of languages or something like that.. but my memory is faulty.
Re: Best of show – abuse of libc
#40Earlier quoted context omitted.
Hm, I think you could add numeric syscalls, similar to what happens at the asm level. E.g. put the syscall id and some parameters on the "stack", then let the interpreter run the syscall with a new "instruction" e.g. '!'. This could even substitute '.' (putchar) and ',' (getchar), since these are very much just syscalls. So that would reduce the number of instructions by one (to 7). Oh, getting to 6 would also be fun…
It's already implemented: https://github.com/ajyoon/systemf There is even an HTTP server built with it.