Check and truncate strings which are too long.

LibYAML uses int for string lengths rather than size_t.