I'm making a network program/game and I want to prevent clients from ........ing up the buffers.
char buf[x] has a limit... is there a way to make x dependent on user input? (strlen or something).
Printable View
I'm making a network program/game and I want to prevent clients from ........ing up the buffers.
char buf[x] has a limit... is there a way to make x dependent on user input? (strlen or something).
Read everything into a fixed-length buffer initially. All the good input functions allow you to specify a buffer and a length.
When you've got the buffer and its actual length, then allocate whatever memory you need to store that (linked list, array, whatever) and copy from your input buffer to you allocated memory.
Rinse and repeat until you have all the input you need.