If you're not trusting enough to assume that the size is 32, you need to compare the sizes of a and b before calling memcmp as well.