-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix buffer overflow in chat server example #1
Fix buffer overflow in chat server example #1
Conversation
Please update to strncpy() as @phoem suggested. If we're fixing buffer overflows we might as well go all the way. |
strncpy is insufficient however. strncpy_s at the very least. Brian Hook On Tue, Jul 8, 2014 at 2:19 PM, Alex Howland notifications@github.com
|
strncpy_s is MS only though. RakNet is cross-plat. |
I would recommend that you just grab the source to a safe string copy from Brian Hook On Tue, Jul 8, 2014 at 5:22 PM, Alex Howland notifications@github.com
|
I left the initial strcpy in-place as it is obviously safe due to the static source and desitnation size and the static source data, and to minimize the impact of the change. Is it desirable to replace all uses of strcpy solely for consistency/maintenance reasons? It's not clear to me what the benefit of using the MSVC-specific I've corrected a typo in the original PR. |
strcpy can be safe when you look at each instance and verify that it's So it's good practice to just make them all buffer safe (as much as strncpy doesn't necessarily null terminate the string and this can Any widespread network codebase really needs buffer safe versions of Brian Hook On Tue, Jul 8, 2014 at 9:57 PM, Benjamin Saunders notifications@github.com
|
I've dropped in strncpy as per discussion. I'll leave the addition of strlcpy, with proper measures to ensure linking on BSDs is not interfered with, to another PR. OpenBSD's libc is, of course, BSD-licensed, so its implementation should suit. |
What @BrianHook said: just because it fits now doesn't mean it will still fit later on when a change is made. |
I'm going to pull this in now, but we can talk about |
Fix buffer overflow in chat server example
Raknet - pull request facebookarchive#4
…apply_fix_large_packets_support Feature/apply fix large packets support
message
, which contains at most 2048 bytes, was previously copied after a prefix intomessage2
, which has a size of 2048 bytes, with no bounds checking. This could result in a stack overflow ofstrlen("Server: ")
bytes.