base: Implement JSON string escaping

We encode JSON in the KDC's audit logs, and soon in bx509d's /get-tgts.
Therefore, we should be reasonable in terms of what we encode.
This commit is contained in:
Nicolas Williams
2022-09-11 00:28:00 -05:00
parent 7ae4292986
commit c6a46f0c96
4 changed files with 937 additions and 80 deletions

View File

@@ -153,7 +153,8 @@ heim_string_create_with_bytes(const void *data, size_t len)
s = _heim_alloc_object(&_heim_string_object, len + 1);
if (s) {
memcpy(s, data, len);
if (len)
memcpy(s, data, len);
((char *)s)[len] = '\0';
}
return s;