davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.01k stars 250 forks source link

Fix a potential log spamming and DOS attack #308

Closed kulkom closed 1 year ago

kulkom commented 1 year ago

What does this do and why is this needed?

I have discovered an attack that allows you to attack any non-trivial programs that use onion. At the very least it allows you to spam the logs with a few hundred thousand useless messages, and maybe even deny service to other clients. And the worst part about it? You only need Firefox (maybe Chrome can do it as well, I haven't tested that) and a functional F5 key.

To reproduce it:

  1. Download, compile and run the source file below, it's a program that simulates a non-trivial onion app by writing 200000-something chars when requested at <Your IP>:8080/teapot.
  2. Download Mozilla's finest web browser if you don't have it already.
  3. Open up Firefox and browse to localhost:8080/teapot.
  4. Make sure the Firefox window is in focus and hold down the F5 key for a few minutes.
  5. That's it. Now the logs are full of pointless messages and for me the program stopped responding for ~30 seconds.
C source file ``` #include #include "onion/src/onion/onion.h" #include "onion/src/onion/response.h" static onion_connection_status be_a_teapot (void * _, onion_request * req, onion_response * rsp) { (void) _; (void) req; onion_response_set_code (rsp, 418); onion_response_printf (rsp, "%s", "

418.

I'm a teapot.


The resulting entity body is NOT short and stout.
Tip me over and pour me out AND ENJOY THE USELESS INVISIBLE A's BELOW.

"); for (unsigned int i = 0; i < 200000; ++i) onion_response_printf (rsp, "%c", 'A'); onion_response_printf (rsp, "%s", "

"); return OCS_PROCESSED; } int main () { onion * webserver = onion_new (O_THREADED); onion_url * webserver_urls = onion_root_url (webserver); onion_url_add (webserver_urls, "teapot", be_a_teapot); onion_set_hostname (webserver, "0.0.0.0"); onion_listen (webserver); onion_free (webserver); return EXIT_SUCCESS; } ```

So, how does it work?

It's quite simple: when Firefox refreshes, it'll reset all current connections with the server, if any, and then it'll reconnect. Thus, by holding down F5 Firefox will connect to the server and reset that connection almost immediately and will continue doing that while the key is being held down. When the connection is reset, onion will complain about being unable to write the chunk encoding length in a warning, which is reasonable behavior most of the time - but not always. By connecting and resetting countless times we'll not only create a bunch of useless warnings in the log, but we'll also make all the threads very busy writing that log down to the stdout (or syslog). And, quite obviously, when a thread is writing a warning to the log it's not doing any serving, and when all threads are writing to the log the client will not get served at all.

The fix

The fix is as simple as the problem: allow onion to log a chunk encoding write error only once a second, and at other times just count the errors and output the count if an error occurs after a second since the previous warning had been written.

Logs of the sample program before the commit

Some onion logs ``` [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A14E5640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9F4E1640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [9FCE2640] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. [A24E8740] [2022-08-30 02:46:51] [WARNING response.c:436] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. ```

Logs of the sample program after the commit

Some more onion logs ``` [76D4D640] [2022-08-30 02:37:25] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 200298 (Keep-Alive) [76D4D640] [2022-08-30 02:37:25] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 200298 (Keep-Alive) [76D4D640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [7754E640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Connection reset by peer. Aborting write. (x1) [79D54740] [2022-08-30 02:37:26] [ERROR response.c:470] Error writing 1500 bytes (Broken pipe). Maybe closed connection. Code -1. [79D54740] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [77D4F640] [2022-08-30 02:37:26] [ERROR response.c:470] Error writing 1500 bytes (Broken pipe). Maybe closed connection. Code -1. [77D4F640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [78550640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [78D51640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [79552640] [2022-08-30 02:37:26] [ERROR response.c:470] Error writing 1500 bytes (Broken pipe). Maybe closed connection. Code -1. [79552640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [77D4F640] [2022-08-30 02:37:26] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 120564000 (Keep-Alive) [79D53640] [2022-08-30 02:37:26] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x1) [77D4F640] [2022-08-30 02:37:26] [ERROR response.c:470] Error writing 1500 bytes (Broken pipe). Maybe closed connection. Code -1. [76D4D640] [2022-08-30 02:37:26] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 255475500 (Keep-Alive) [7754E640] [2022-08-30 02:37:26] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 289203000 (Keep-Alive) [7754E640] [2022-08-30 02:37:26] [ERROR response.c:470] Error writing 1500 bytes (Broken pipe). Maybe closed connection. Code -1. [79552640] [2022-08-30 02:37:26] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 221746500 (Keep-Alive) [79D54740] [2022-08-30 02:37:26] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 120564000 (Keep-Alive) [76D4D640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x290018) [79552640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x228379) [77D4F640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x110453) [78D51640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x65054) [79D53640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x49581) [78550640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x81892) [79D54740] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x81263) [7754E640] [2022-08-30 02:37:27] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x230463) [76D4D640] [2022-08-30 02:37:27] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79552640] [2022-08-30 02:37:27] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [76D4D640] [2022-08-30 02:37:27] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79552640] [2022-08-30 02:37:27] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79552640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x444114) [78550640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x53793) [76D4D640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x396747) [78D51640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x59457) [79D53640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x58540) [79D54740] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x55083) [77D4F640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x62441) [7754E640] [2022-08-30 02:37:28] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x57029) [79552640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [76D4D640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79D53640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [78D51640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [78550640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [77D4F640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 291450000 (Keep-Alive) [7754E640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 286953000 (Keep-Alive) [79D54740] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79552640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [7754E640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 200298 (Keep-Alive) [76D4D640] [2022-08-30 02:37:28] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [78550640] [2022-08-30 02:37:29] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x147911) [79D53640] [2022-08-30 02:37:29] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x184922) [78D51640] [2022-08-30 02:37:29] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x176673) [77D4F640] [2022-08-30 02:37:29] [WARNING response.c:453] Error writing chunk encoding length (5DC) Broken pipe. Aborting write. (x208733) [77D4F640] [2022-08-30 02:37:29] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [79D53640] [2022-08-30 02:37:29] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [78550640] [2022-08-30 02:37:29] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) [78D51640] [2022-08-30 02:37:29] [INFO response.c:196] [127.0.0.1] "GET /teapot" 418 298197000 (Keep-Alive) ```
kulkom commented 1 year ago

Hi @davidmoreno , is there anything wrong with this commit that you don't want to merge it? Please let me know if that's the case, thanks.

davidmoreno commented 1 year ago

Hi,

first of all thanks for the full report, very detailed. Appreciated.

I have had not much time for reviewing, but some details:

Both ideas are in the same line of making the code at the place of use very concise and easy to read. And create infrastructure so it can be reused.

Regards, David.

kulkom commented 1 year ago

Roger! To be honest I really should have thought better especially about the huge define section, I simply googled "c cross platform thread local" lol. Will fix both points once I have free time.

Thanks for the quick reply.

kulkom commented 1 year ago

@davidmoreno Is it good enough now?

davidmoreno commented 1 year ago

Very good indeed! Thanks!