This looks wrong. You probably mean strncmp? memcmp will always read 5 bytes, even if the string ends before that.