News for hackers. Stuff that matters.
Re:Google paid a $250K reward for a bug by probably_wrong on Thursday August 14, 2025 @05:44AM (#44898566)
The string length in C is "whatever number of bytes are there between the beginning of the string and the first \0 character". That's different from "how much memory is being used by this string" because you usually allocate a bigger buffer.

The length of the string "Foo", when properly terminated, is 3. The minimum number of bytes needed [1] to represent that string properly is 4 (3+'\0'). The actual number of bytes used by that string is whatever you asked for and received when using "malloc".

[1] Assuming ASCII and 1-byte characters.

There are no comments on this comment yet.