Helper function get_label()

The helper function ssize_t get_label(char *dest, const char *src)
validates the given label and copies it to the dest buffer if
available.
Copy labels using get_label()

Copy and validate labels in a single transaction:

- No trust for having '\0' in the src buffer when copying
  labels.
- Improves performance by combining length calculation, validation
  and copying.