From fbc51366e6c5572049915e5abade43a80d8e0150 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 30 Apr 2022 21:48:48 +0100 Subject: [PATCH] u/config: Avoid using strncpy --- src/xrt/auxiliary/util/u_config_json.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xrt/auxiliary/util/u_config_json.c b/src/xrt/auxiliary/util/u_config_json.c index 92db2f699..d7229d28c 100644 --- a/src/xrt/auxiliary/util/u_config_json.c +++ b/src/xrt/auxiliary/util/u_config_json.c @@ -490,12 +490,12 @@ u_config_json_save_overrides(struct u_config_json *json, struct xrt_tracking_ove cJSON_AddStringToObject(entry, "target_device_serial", overrides[i].target_device_serial); cJSON_AddStringToObject(entry, "tracker_device_serial", overrides[i].tracker_device_serial); - char override_type[256]; + char buffer[256]; switch (overrides[i].override_type) { - case XRT_TRACKING_OVERRIDE_DIRECT: strncpy(override_type, "direct", 256); break; - case XRT_TRACKING_OVERRIDE_ATTACHED: strncpy(override_type, "attached", 256); break; + case XRT_TRACKING_OVERRIDE_DIRECT: snprintf(buffer, ARRAY_SIZE(buffer), "direct"); break; + case XRT_TRACKING_OVERRIDE_ATTACHED: snprintf(buffer, ARRAY_SIZE(buffer), "attached"); break; } - cJSON_AddStringToObject(entry, "type", override_type); + cJSON_AddStringToObject(entry, "type", buffer); cJSON_AddItemToObject(entry, "offset", make_pose(&overrides[i].offset));