The length of the string (text data) is determined by the position of the NULL character, which indicates the end. In the case of binary data, NULL can be and often is in the middle of the data.
You do not check the length of the binary data. You must know this beforehand. In your case, the length is 16 (bytes, not bits if it's a UUID).
Regarding the validity of the UUID, any 16-byte value is a valid UUID, so you're out of luck there.
source
share