From: Nikola Pajkovsky Date: Wed, 15 Oct 2025 10:48:06 +0000 (+0200) Subject: clang deprecates sprintf on macos X-Git-Tag: 3.6-PRE-CLANG-FORMAT-WEBKIT~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea4ae337b9fa96ba50d715629efd18f0a83b0c0a;p=thirdparty%2Fopenssl.git clang deprecates sprintf on macos test/threadstest.c:1376:9: error: 'sprintf' is deprecated. The same issues is in the ossl-nghttp3-demo. Signed-off-by: Nikola Pajkovsky Reviewed-by: Saša Nedvědický Reviewed-by: Richard Levitte Reviewed-by: Tomas Mraz Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28903) (cherry picked from commit 60e699a4549779f72b8621415b7565d422127285) --- diff --git a/demos/http3/ossl-nghttp3-demo-server.c b/demos/http3/ossl-nghttp3-demo-server.c index 2b44fb8b142..52ac77f0a77 100644 --- a/demos/http3/ossl-nghttp3-demo-server.c +++ b/demos/http3/ossl-nghttp3-demo-server.c @@ -1166,17 +1166,17 @@ static int run_quic_server(SSL_CTX *ctx, int fd) /* We don't find the file: use default test string */ h3ssl.ptr_data = nulldata; h3ssl.ldata = nulldata_sz; - sprintf(slength, "%zu", h3ssl.ldata); + snprintf(slength, sizeof(slength), "%zu", h3ssl.ldata); /* content-type: text/html */ make_nv(&resp[num_nv++], "content-type", "text/html"); } else if (h3ssl.ldata == INT_MAX) { /* endless file for tests */ - sprintf(slength, "%zu", h3ssl.ldata); + snprintf(slength, sizeof(slength), "%zu", h3ssl.ldata); h3ssl.ptr_data = (uint8_t *) malloc(4096); memset(h3ssl.ptr_data, 'A', 4096); } else { /* normal file we have opened */ - sprintf(slength, "%zu", h3ssl.ldata); + snprintf(slength, sizeof(slength), "%zu", h3ssl.ldata); h3ssl.ptr_data = (uint8_t *) get_file_data(&h3ssl); if (h3ssl.ptr_data == NULL) abort(); diff --git a/test/threadstest.c b/test/threadstest.c index e85bb8c8eec..685e8b47bfb 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -1373,7 +1373,7 @@ static void test_obj_create_worker(void) for (i = 0; i < 4; i++) { now = time(NULL); - sprintf(name, "Time in Seconds = %ld", (long) now); + snprintf(name, sizeof(name), "Time in Seconds = %ld", (long) now); while (now == time(NULL)) /* no-op */; nid = OBJ_create(NULL, NULL, name);