core: Use libc::readlink function properly

The specification of readlink() says it's not guaranteed that the
returned contents of the symbolic link is null-terminated.

Source: [POS30-C. Use the readlink() function properly](https://www.securecoding.cert.org/confluence/display/seccode/POS30-C.+Use+the+readlink%28%29+function+properly>)