loader/cJSON: replace sprintf calls with snprintf
authorMark Mentovai <mark@chromium.org>
Mon, 7 Nov 2022 15:11:03 +0000 (10:11 -0500)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Mon, 7 Nov 2022 19:08:20 +0000 (12:08 -0700)
commit6b0551428e57b9d610c4b5cf098448a6c0d2a565
tree87ff0c3686e42001a42df93a5ee274cc6c5a9891
parent8ff839bda370f2a46708f117b551ff0ea7954416
loader/cJSON: replace sprintf calls with snprintf

This makes it possible to build Vulkan-Loader without warnings using the
macOS 13 SDK. Calls to sprintf are replaced with snprintf, passing
appropriate buffer sizes.

It doesn’t appear that any of the changed uses of sprintf were actually
unsafe, so no behavior change is expected aside from SDK compatibility.

The macOS 13 SDK deprecates sprintf as it’s difficult to use safely. The
deprecation warning message is visible when building C++, but it is not
normally visible when building plain C code due to a quirk in how
sprintf is declared in the SDK. However, the deprecation message is
visible when building plain C under Address Sanitizer
(-fsanitize=address). This discrepancy was discovered at
https://crbug.com/1381706 and reported to Apple with a copy at
https://openradar.appspot.com/FB11761475.

The macOS 13 SDK is packaged in Xcode 14.1, released on 2022-11-01. This
also affects the iOS 16 SDK and other 2022-era Apple OS SDKs packaged in
Xcode 14.0, released on 2022-09-12.

Vulkan-Loader is visible to the Chromium build via PDFium, and this
change is needed to allow Chromium to move forward to the macOS 13 SDK.
loader/cJSON.c