The ups and downs of strlcpy()
The ups and downs of strlcpy()
Posted Jul 24, 2012 6:37 UTC (Tue) by kleptog (subscriber, #1183)In reply to: The ups and downs of strlcpy() by nix
Parent article: The ups and downs of strlcpy()
It's not perfect of course, if the client is using SSL then you have to rely on the SSL library to not do anything silly but it's worked every time for me. On the client you get a nice message along the lines of "server ran out of memory". Your transaction is aborted, but the rest of the server is still running.
This obviously only works if malloc() returns NULL, so memory overcommit needs to be off. OOM during stack growth is uncatchable, you can only try to mitigate the risk bit keeping your stack small.
I just wanted to point out that it is possible to create code that handles OOM, and it's not helpful if libraries assume they can just die in that case.