logging: make sure the output is null-terminated

If we reach the buffer size or snprintf fails, we want to make sure
that the output is null-terminated.
diff --git a/src/logging.c b/src/logging.c
index 6797afc..0911010 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -493,6 +493,7 @@
 		goto err;
 	OSMO_SNPRINTF_RET(ret, rem, offset, len);
 err:
+	str[size-1] = '\0';
 	return str;
 }
 
@@ -544,6 +545,7 @@
 		OSMO_SNPRINTF_RET(ret, rem, offset, len);
 	}
 err:
+	str[size-1] = '\0';
 	return str;
 }