Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're trying to allocate 20000 bytes on the stack. Firstly, that may be the cause of the crash. You shouldn't even be attempting that, and I'm not going to tell you a better way to allocate buffers, because the whole approach is wrong, so I'd just be helping you to get the wrong idea to limpingly work.</p> <p>@mbratch is utterly wrong about sizeof(). You have no way to know that the result string is always exactly sizeof(resp_buf) bytes long a priori, and in fact, the code you posted makes a string that's nowhere near that long. So this would write some data and a lot of garbage, which is very likely not what you want.</p> <p>What happens when (later on, perhaps in response to a request from Marketing) this error HTML gets modified? Are you planning to recompile your program every time they change their mind about the copy? That's not my idea of fun. Please Google for 'open coding' aka 'hard coding' and 'anti patterns'.</p> <p>You shouldn't be using the printf family of functions when the first arg is not a format string wholly under your control, else you risk format string vulnerabilities. Google for that too. Crackers love people like you. In your case it's a constant string, not a format string.</p> <p>You probably want something more like using fdopen to convert your fd into a FILE *, followed by use of fputs, with the data coming from a file. But more likely you really want to be using PHP or a CMS or something.</p> <p>I think you should be seriously asking yourself why you are trying to write the world's crappiest web server with only a tiny amount of C knowledge. Apache is very good at serving files to the Web.</p> <p>You've failed to tell us what you're trying to achieve, thus preventing us from helping you to avoid that.</p> <p>I would vote this question down even more than already, if I could.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload