3 ms·
Ha. Kind of like PHP's function name lengths being used as a "hash" back in the day. But, what contexts is this function used in? Is it supposed to be one-way
by function_seven 11y ago
Ha. Kind of like PHP's function name lengths being used as a "hash" back in the day.
But, what contexts is this function used in? Is it supposed to be one-way at all? If not, then this is just a simple way of distributing vrf/ip pairs into buckets. Still smells funny, though.
EDIT: This comment looks like I'm defending the implementation here. I'm not. Seems like it'd me more uniform to just add the bytes in the vrf/IP pair and mod them with something. Seeing a hyphen in the format string of sprintf() is really weird, considering that just he string's length is being used.
Again, assuming this is in no way security-related, then this is just a general, run-of-the-mill WTF.
- Animats 11y agoAn unchecked "sprintf" is a potential buffer overflow, especially in something like this where the input and output string buffers are parameters to the function. I didn't even go looking for bad code. I was just curious to see what language they were using. This was near the top of the first file I looked at. The code looks like C code circa 1990. If a first glance turned up this, what else bad is in there?
- ArkyBeagle 11y agoWhether this is bad in practice depends. It is declared static, so it's just a small helper function, not a major API entry point. In a review, I'd call out requirements for buffer overflow detection outside this function.