strlen returns the number of characters that precede the terminating null character. An implementation of strlen might look like this:
strlen
Yes, it's undefined behaviour. From the draft C11 standard, §J.2 "Undefined behavior":
The behavior is undefined in the following circumstances: ... The value of an object with automatic storage duration is used while it is indeterminate.
The behavior is undefined in the following circumstances:
...
The value of an object with automatic storage duration is used while it is indeterminate.